> I use structures to pass back multiple things from > functions, but I'm not so > sure you're right about not using an array. An array maps > to the > cfprocresult's resultset attribute(as it could equally to > it's name attrib) > but with the array you don't need to know the name used > only the number of > the resultset.
> I hope that makes sense, I've just had a not so powerful > power nap and I > tell ya, it hasn't done anything for my thinking just this > minute. > Ade Well my comments weren't really with regard to the procedure itself per se... I realize that the stored procedure only offers the number of the result set to inform you about what's in it (unless you get creative with output variables), but rather, if I'm just looking at a piece of code and I see this: <cfset mydata = cfc.getData()> <cfoutput query="mydata[1]">...</cfoutput> That's going to make a heck of a lot _less_ sense to me reading it as this: <cfset mydata = cfc.getData()> <cfset qeury="mydata.products">...</cfoutput> The latter is rather self-documenting -- you know simply from reading it what it is... The former, having only a number is obscure and leads to programmers wondering what the hell is going on and then needing to go investigate further in order to understand it. This is in general a frequent problem with code that I see submitted to the cf-talk list (or in other places), I think particularly with programmers who come to CF from other languages where associative arrays are less friendly to use, like Java or ASP, where rather than using the extraordinarily simple and self-explanatory CF structure, they resort to an array and a collection of numeric variables. I see this frequently in Java class documentation on the Sun site, where the class has public properties like STATUS_AVAILABLE = 1 : STATUS_CANCELLED = 2 : and then in order to actually know what the object is doing you have to compare method results to these public properties instead of simply using the method result. And this sort of thing I _think_ often translates when people come to CF from other languages to ugly codeblocks like this: <cfset productname = 1> <cfset qty = 2> <cfset unitcost = 3> <cfset totalcost = 4> <cfset product = ArrayNew(1)> <cfset shoppingcart[arraylen(shoppingcart)] = product> <cfset product[productname] = myquery.productname> <cfset product[qty] = form.quantity> <cfset product[unitcost] = myquery.unitcost> <cfset product[totalcost] = product[qty] * procut[unitcost]> Instead of something more efficient, elegant, legible and bulletproof like this: <cfset product = queryToStruct(myquery)> <cfset product.qty = form.quantity> <cfset product.totalcost = product.qty * product.unitcost> Granted that I have taken the liberty of using a function to convert the query into a structure in this example (a good habbit anyway), which also eliminates a good bit of the code, but just simply not having the local variables for productname, qty, unitcost and totalcost just to be able to know where the item is in the array is a subtle but powerful thing. Consider for a moment if you hand off the original code using the array to another programmer who'd hever seen the code before or never worked with ColdFusion and they need to debug it. You might expect if they've read about ColdFusion a little they might use <cfdump> to display the contents of the shopping cart... and to their shock and dismay they would be met with a huge list of completely arbitrary and meaningless numbers, each associated with an arbitrary string which may or may not be what they think it is. Then they'd have to start comparing the local variables productname, qty, unitcost and totalcost to those numbers in order to figure out what's what. If they're bright, they'll figure this out right away and they'll start making the association as they flip back and forth between their browser and the code and they'll probably figure it out in a reasonably short period of time, but honestly, why put them through the trouble? Why make it more difficult for them - why make them have to think about that association of the arbitrary number "2" to the intuitively obvious name "qty" at all when it's _easier_ to just use the CF native structure and let them know _instantaneously_ what everything is from looking at the dump output? Anyway -- that's the end of my rant. :) s. isaac dealey 954.522.6080 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/story/?storyid=44477&DE=1 http://www.sys-con.com/story/?storyid=45569&DE=1 http://www.fusiontap.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:197570 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

