RE: Help: Can arrays be used like queries

2000-04-08 Thread Emily B. Kim

Chris Evans wrote:
1) I don't use just lists.  I just tend to use lists rather than arrays.  I
love using structures :).
3) I'm getting to run some speed tests to prove Nick's comment about speed
increases of arrays over lists.  That is a good reason to use arrays over
lists.

sorry for the belated response...but i wasn't arguing with you chris! :)
just wanted to see some code. always interested in learning new ways to do
things. if you come up with some benchmark numbers, could you share,
please? thanks! -emily
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



RE: Help: Can arrays be used like queries

2000-04-05 Thread Chris Evans

Emily,

  A couple of points:

1) I don't use just lists.  I just tend to use lists rather than arrays.  I
love using structures :).

2) In the shopping bag example, for the store, the key would be the users
session ID.  I could do it with lists if I wanted.  Remember, a
3-dimensional array is nothing more than an array of arrays of arrays.
Since a 1- dimensional array is really a list, I could (and have) create a
list of lists of lists.  I wouldn't do that now, but I would have a version
or two ago.

3) I'm getting to run some speed tests to prove Nick's comment about speed
increases of arrays over lists.  That is a good reason to use arrays over
lists.

The biggest annoyance I have with arrays is that there always seems to be a
lot of looping and other programming overhead involved.  I do some
programming in C++ and Java, and use arrays and looping in those languages,
but in CF that creates a lot of overhead.


Chris Evans
[EMAIL PROTECTED]
http://www.fuseware.com


-Original Message-
From: Emily B. Kim [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 05, 2000 12:14 AM
To: [EMAIL PROTECTED]
Subject: RE: Help: Can arrays be used like queries


  Hopefully not any different than the way you would do it in an array.  In
your example below, I would have a structure for Product 1, a structure for
Product 2, and so on.  I would also have an ItemInYourBag structure, with
the key being the product ID and the value being the quantity.  If the
product had more attributes, such as color or size, they would just be more
members of the ItemInYourBag structure.

The only list I would maintain would be the list of items in your bag,
which
is the same as the StructKeyList(ItemInYourBag).

I don't think this helped explain why I prefer lists rather than arrays, as
my solution would be structures of structures.

yeah, i think that you can't do something that complex with just lists. you
would have to work with arrays and/or structures. the only "problem" i can
see with the structure of structures you have above has to do with what
would you be using as your key for the outer structure? you would have to
dynamically generate it, which seems like it would be more effort than just
using the index that is inherent in an array. -emily

--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



RE: Help: Can arrays be used like queries

2000-04-04 Thread Chris Evans

David,

  You can also use queries as arrays.  For example, if I have a query called
"Articles" with a column named "TITLE", and I want the 5th
row, I can use Articles.Title[5].

I rarely see a need for arrays with CF, though other programmers seem to use
them for everything.  I don't quite understand that.  I've seen a lot of
programming, even custom tags, that translate native CF data elements into
arrays, when it is easier to use the native data element.

Chris Evans
[EMAIL PROTECTED]
http://www.fuseware.com


-Original Message-
From: David Cummins [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 03, 2000 7:10 PM
To: [EMAIL PROTECTED]
Subject: Help: Can arrays be used like queries


Hi all,

I don't know if this is possible, but can arrays or any other ColdFusion

structures be used like queries, i.e. cfoutput
query="arrayorsomething", or converted to a query?

It's just that it could be a pain converting pages that were initially
created to use queries to use loops on arrays instead, and named columns

make for more programmer-friendly pages.

TIA

David Cummins
Ubiquity Software Ltd.




--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



Re: Help: Can arrays be used like queries

2000-04-04 Thread Emily B. Kim

   You can also use queries as arrays.  For example, if I have a query called
 "Articles" with a column named "TITLE", and I want the 5th
 row, I can use Articles.Title[5].

just a fyi, although you can use array syntax to reference queries,
remember that queries are NOT arrays so you can't use the array
functions on them.

 I rarely see a need for arrays with CF, though other programmers seem to use
 them for everything.  I don't quite understand that.  I've seen a lot of
 programming, even custom tags, that translate native CF data elements into
 arrays, when it is easier to use the native data element.

arrays are very useful for passing information without having to write
to the DB. think of use of an array of structures for a shopping cart.
-emily
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



RE: Help: Can arrays be used like queries

2000-04-04 Thread Chris Evans

I always end up using lists rather than arrays, though a list can be thought
of as a 1-dimensional array.  So I would use a list of structures rather
than an array of structures.  I find Lists easier to create and maintain
than arrays.

Chris Evans
[EMAIL PROTECTED]
http://www.fuseware.com


-Original Message-
From: Emily B. Kim [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 04, 2000 10:39 AM
To: [EMAIL PROTECTED]
Subject: Re: Help: Can arrays be used like queries


   You can also use queries as arrays.  For example, if I have a query
called
 "Articles" with a column named "TITLE", and I want the 5th
 row, I can use Articles.Title[5].

just a fyi, although you can use array syntax to reference queries,
remember that queries are NOT arrays so you can't use the array
functions on them.

 I rarely see a need for arrays with CF, though other programmers seem to
use
 them for everything.  I don't quite understand that.  I've seen a lot of
 programming, even custom tags, that translate native CF data elements into
 arrays, when it is easier to use the native data element.

arrays are very useful for passing information without having to write
to the DB. think of use of an array of structures for a shopping cart.
-emily

--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



RE: Help: Can arrays be used like queries

2000-04-04 Thread Nick Slay

I don't have any exact figures. Ben Forta did a session on Advanced Tips 
and Tricks, and that was one of them.  It was related to the fact that a 
list is essentially a string, and ColdFusion has to read through that 
string to find the next delimiter.  Every time you wanted to access an 
element, it had to go through the list checking each character to see if it 
is the delimiter or not (at least that is my understanding.. I'll recheck 
my notes!)

One of the questions that was asked was whether it would be better to 
convert to an array and then work on the array until you were done, and 
then put it back out to the list... the answer to that was yes.   So if you 
must use lists, and need to do much work with them in a script, convert to 
an array first.

Lists are best used for Form results (ie, multiple selects) and in a SQL 
WHERE clause (ie, WHERE xx IN (#listname#)).  Arrays are faster than lists, 
but Structures are the fastest

And if you need to do much work with a single element (this goes for lists, 
arrays and struct), then copy that element out to a normal variable before 
doing anything else, and re-add it to the list when finished with it.

Maybe if I get the time, I'll go through all the notes I took and post a 
message of Tips and Tricks!!  There are lots of obvious ones..

1) Reduce the number of db calls, for example, use stored procedures and 
triggers, referential integrity (and CFTRY/CFCATCH to catch the database 
errors, this is quicker than letting CF process the forms for errors).

2) CFLOOP vs CFOUTPUT was another... CFLOOP is faster than CFOUTPUT... 
however, as a rule of thumb, if you are only listing fields from the 
recordset in CFOUTPUT, then use that.  If you are doing additional work, 
then use CFLOOP.

3) Use CFPARAM, rather than checking for Defined/Null.

4) Evaluate/DE are VERY intensive.  Use wisely!

5) Custom Tags are recommended over Includes because of the scope of 
variables... include files take the parent's scope, and so if you edit an 
include file, that is used on many pages, and add a new variable... results 
could be unpredictable if you have already used that same variable name 
elsewhere.

etc etc etc etc :^)

Nick



At 18:00 4/04/00 -0400, you wrote:
Really!  That's the first I heard of that. I always thought that Lists would
be faster.  I always see code where users convert list to arrays, and I
would expect that would be more overhead.  Do you ( or anybody) have any
more detail on performance gain of arrays over lists?


Chris Evans
[EMAIL PROTECTED]
http://www.fuseware.com


-Original Message-
From: Nick Slay [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 04, 2000 5:24 PM
To: [EMAIL PROTECTED]
Subject: RE: Help: Can arrays be used like queries


Hi Chris...

Just thought I'd mention this tip that I picked up from ColdFusion-master
Ben Forta at a developer conference a few weeks back

'Try and avoid using lists.  They are a lot slower than Array's or
Structures.  They are easier to use, but at a cost to performance.'

Regards

Nick



At 10:56 4/04/00 -0400, you wrote:
 I always end up using lists rather than arrays, though a list can be
thought
 of as a 1-dimensional array.  So I would use a list of structures rather
 than an array of structures.  I find Lists easier to create and maintain
 than arrays.
 
 Chris Evans
 [EMAIL PROTECTED]
 http://www.fuseware.com
 
 
 -Original Message-
 From: Emily B. Kim [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, April 04, 2000 10:39 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Help: Can arrays be used like queries
 
 
 You can also use queries as arrays.  For example, if I have a query
 called
   "Articles" with a column named "TITLE", and I want the 5th
   row, I can use Articles.Title[5].
 
 just a fyi, although you can use array syntax to reference queries,
 remember that queries are NOT arrays so you can't use the array
 functions on them.
 
   I rarely see a need for arrays with CF, though other programmers seem to
 use
   them for everything.  I don't quite understand that.  I've seen a lot of
   programming, even custom tags, that translate native CF data elements
into
   arrays, when it is easier to use the native data element.
 
 arrays are very useful for passing information without having to write
 to the DB. think of use of an array of structures for a shopping cart.
 -emily
 ---
-
 --
 Archives: http://www.eGroups.com/list/cf-talk
 To Unsubscribe visit
 http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
 send a message to [EMAIL PROTECTED] with 'unsubscribe' in
 the body.
 
 
 ---
---
 Archives: http://www.eGroups.com/list/cf-talk
 To Unsubscribe visit
 http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
 send a message to [EMAIL PROTECTED] with 'unsub

RE: Help: Can arrays be used like queries

2000-04-04 Thread Emily B. Kim

  Hopefully not any different than the way you would do it in an array.  In
your example below, I would have a structure for Product 1, a structure for
Product 2, and so on.  I would also have an ItemInYourBag structure, with
the key being the product ID and the value being the quantity.  If the
product had more attributes, such as color or size, they would just be more
members of the ItemInYourBag structure.

The only list I would maintain would be the list of items in your bag, which
is the same as the StructKeyList(ItemInYourBag).

I don't think this helped explain why I prefer lists rather than arrays, as
my solution would be structures of structures.

yeah, i think that you can't do something that complex with just lists. you
would have to work with arrays and/or structures. the only "problem" i can
see with the structure of structures you have above has to do with what
would you be using as your key for the outer structure? you would have to
dynamically generate it, which seems like it would be more effort than just
using the index that is inherent in an array. -emily
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.