In CFC, I always do this: <cffunction name = "something"> <cfargument name="some" required="true" type="string"/> <cfset var few = arguments.some/> <cfset few = 10/> </cffunction>
If we should always scope our variables. Should I do this? <cfset var variables.few = arguments.some/> <cfset variables.few = 10/> The reason I re-set arguments.some to few is because I want to type 3 letters instead of 14, but if I should always scope my variables, then there is no point of resetting it. Johnny >I believe that scoping is important and removed ambiguity, especially for >developers (including yourself) who may latter have to work on that page. > >I would opine that scoping is a best practice. > >- Calvin > >-----Original Message----- >From: Jim Davis [mailto:[EMAIL PROTECTED] >Sent: Saturday, March 26, 2005 5:34 PM >To: CF-Talk >Subject: RE: Best practice question? > > >When the examples are this simple it doesn't really show why you would do >the latter - but in many cases the code between a CFOUTPUT can be very long >and complex. > >It's almost always better to know where a variable came from. > >As for performance scoping a variable is almost always more performant - >without the scope identifier CF has to do a scope chain lookup to determine >where the variable is. > >Inside a CF output that scope chain look up begins with the query so it's >still fast, but scoping is definitely not slower. > >Jim Davis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| 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:200141 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

