On Thu, 3 Mar 2005 20:51:45 -0000, Adrian Lynch
<[EMAIL PROTECTED]> wrote:
> I don't see how using structures over arrays improves encapulation. Granted
> standardising the naming of the resultsets will help but how can it be
> better in having to know the names of two variables inside another
> function/cfc method?
>
> Good call on the value/reference point though, that always slips me by.
>
> Ade
I don't really see how it aids enapsulation either, but I do know that
you don't need to know the names of your collection elements in order
to loop it:
<cfloop collection="#dataStruct#" item="i">
#i# = #dataStruct[i]#<br>
</cfloop>
This gets access to your collection (structure variable) the same way
an index loop would get you access to an array:
<cfloop from="1" to="#arrayLen(myArray)#" index="i">
#myArray[i]#<br>
</cfloop>
However, because of the structure's properties as an associative
array, you have the extra readability and clarity when using cfoutput
in a loop, cfdump, or any other method to reveal your variable's
contents. Add to that the byRef (pass) vs. byVal (copy) difference
between the two and I think there's compelling reason to use structs
where possible instead of arrays.
Aside from that, now that we have the ability to use array-style
notation on structs, from a basic coding perspective there's no real
difference other than the aforementioned benefits. And I don't think
the numerical aspects of an array's indexing versus string indexes in
a struct provide enough of a performance boost to justify the
sacrifice of readability (which amounts to maintainability) and
clarity.
Laterz,
J
--
Continuum Media Group LLC
Burnsville, MN 55337
http://www.web-relevant.com
http://cfobjective.neo.servequake.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:197386
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54