> This code creates a tree datatype or object or
> structure...pick your poison.

> <cfset tree = structNew()>
> <cfset tree.braches = 10>
> <cfset tree.leaves = 1500>
> <cfset tree.type = "oak">

> The benefits come when you need a program to generate 500
> trees...

Wouldn't that be when you need to generate 500 trees with semi-random
attributes? ... i.e. If you just need 500 trees, they can all reference a
single instance of Tree ... but if they each need to have certain
semi-random attributes, like the direction they lean, how old / tall they
are, etc, then you can create each new tree with something like
Duplicate(Tree) and then set your 1 or 2 random elements after the
duplicate()...

Though ultimately my big reason for using structures instead of arrays in
most cases is because looking at Tree[3] doesn't tell me that this variable
happens to be the Tree's age, so if I didn't design the template I have to
go hunt down the place where Tree[3] is defined to determine what it is
(especially if the value is a number) ... and that definition may not
necessarily be in the same template -- for that matter, it may be in a
template that's included like <cfinclude template="#url.mytemplate#" in
which case figuring out where it's defined may be the proverbial needle in a
haystack... Tree.Age (if all the variables are well named) virtually
eliminates all that time trying to figure out what it is... Self-documenting
code ... can't beat that. :)

Isaac

www.turnkey.to
954-776-0046

______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to