It's really your preference as you generally won't stand to gain any increased performance by doing it one way or the other. The only other thing to consider is readability and patterns of your code.
My preference is to declare all local variables immediately and initialize them as best as I can. If initialization is based on a conditional, I will declare them with "empty" values first. That way I can always see my arguments and local variables at the top of my functions and don't have to dig around IF logic to find them all. On Monday, June 30, 2014 1:06:54 PM UTC-4, Jason Allen wrote: > > Hey Guys, > > I got another question. > > In some of my more complex cffunction declarations, there's some functions > that I run only if certain requirements or met. So there might be 6 > different function calls, but maybe only 1 or 2 will be used depending on > the arguments passed. > > For instance, as part of a larger 'login' cffunction declaration, I have > the following function call. Thing is, it's part of the code that's most > likely going to be rarely used. > > <cfset var hashPassResults = > application.users.hashPass(password=arguments.password, > userSalt=getPassInfo.userSalt)> > > My question is; should I declare this at the beginning of the function, > then use the 2nd line when it's actually used. Or is it ok to declare the > call the function and declare it as var in one statement? This would avoid > declaring a variable that's rarely used until it's actually needed. > > Start of function: > > <cfset var hashPassResults = structNew()> > > then when actually used... > > <cfset hashPassResults = > application.users.hashPass(password=arguments.password, > userSalt=getPassInfo.userSalt)> > > or do it all when used and don't declare it if not needed > > <cfset var hashPassResults = > application.users.hashPass(password=arguments.password, > userSalt=getPassInfo.userSalt)> > -- -- online documentation: http://openbd.org/manual/ http://groups.google.com/group/openbd?hl=en --- You received this message because you are subscribed to the Google Groups "Open BlueDragon" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
