In order to check for undeclared vars, we have actually test our functions before they're rolled out to production by adding <cfdump var="#variables#"> at the end of the function.
As far as the extensive loops - we have a lot of back-end processes that are actually run via CF and do indeed see that kind of looping. :) Roland -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ben Rogers Sent: Friday, July 08, 2005 4:03 PM To: [email protected] Subject: RE: [CFCDev] Functions local scope > Well guess what you just added the overhead of 100,000 unnecessary > object creations. Youve also added 100,000 StructInsert() calls (the > cfset local.result statement does it implicitly). Not only does this > directly hurt the performance of the code, it also affects the underlying > server processes. Thats now 100,000 additional structs that have to be > Garbage Collected!!! I don't think it's terribly common to see a function called 100,000 times in a single page request. I can't think of a single app that I own that does such a thing. Granted, if you do happen to have a bit a code like that, then avoiding the "local" struct will undoubtedly improve performance. > Anyway, in this case, you obviously would never want to use the local = > StructNew() method, and I run into too many other examples of this type of > code that make it undesirable to use. I think it's far more common to forget to var scope a local variable, causing leakage into the "variables" scope. The "local" struct can help in this respect to the extent that unscoped vars will look wrong. It's also very likely that you'll forget to scope the variable one place and not another, causing ColdFusion to throw an error. As a general rule, I use a "local" struct on any function with more than 3 or 4 local scoped variables or any function that is more than a few lines in length. But that's just a general rule. If I suspect a performance issue, I'll try removing the "local" struct. If I'm auto generating code, I'll skip the "local" struct. On the other hand, if I have a simple function with only 2 or 3 local variables but I suspect I'll be adding functionality in the function, I'll use a "local" struct. > Not to mention I _like_ seeing all > of my variables declared up front. I do too, in languages that force you to declare your variables (e.g. VB w/ Option Explicit). In ColdFusion, I'm not so particular because there's no way to ensure that all the variables are being declared at the top of the function. So, I think it gives a false sense of security ("all the variables at the beginning of my function are declared with the 'var' keyword therefore all the variables in my function must be local"). Ben Rogers http://www.c4.net v.508.240.0051 f.508.240.0057 ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
