> > The speed issue? About the same difference as <cfif vs. > > <cfswitch... > > The main reason I would use switch over if is to make it > easer to read, and easier to maintain. That it is faster > is just a bonus.
This implies that CFSWITCH is always easier to read and maintain, and always faster. I wouldn't agree to either of those. There are cases in which it's easier to read, and other cases in which it isn't. There are cases in which it's faster, I suppose, and other cases in which it's not. I'd guess that the key in both cases is the size of your potential case table. > Thats like saying: > > <CFSET var1 = "this"> > <CFSET var2 = "that"> > <CFSET var3 = "foo"> > <CFSET var4 = "bar"> > > is better than: > > <CFSCRIPT> > var1 = "this"; > var2 = "that"; > var3 = "foo"; > var4 = "bar"; > </CFSCRIPT> > > or that in this case it wouldn't make the most sense to use: > > <CFSCRIPT> > var = arrayNew(4); > var[1] = "this"; > var[2] = "that"; > var[3] = "foo"; > var[4] = "bar"; > </CFSCRIPT> > > The third is both faster and easier to read as far as I am > concerned. While I agree that, in this case, the last example is probably more sensible (using an array makes a concrete statement about the relationships between the values) and thus easier to read, I have no reason to believe it's faster. Do you have such a reason? > Now I hear people say that the amount of time you save is > so small that it's not even worth worrying about, well the > way I see it is if you use ALL the fastest and most optimized > code you can, then it will add up, and be noticeable. Even > if it is not noticeable to a single user, it can also help > reduce your processor load on heavy hit sites. When requests > are over quicker, more requests can be processed faster and so > on. The problem with this statement is that you can never use ALL the fastest and most optimized code, and there are places where your optimization "bang for the buck" is almost certainly better spent. In the above example, for instance, again I have no evidence that it's any faster, or what threshold is needed to make it faster (for example, it may be faster to declare five separate variables than an array with five members, but not so for fifty separate variables vs fifty members, or vice-versa). Very often, when you see these "which is faster" debates, there just aren't any meaningful numbers used to back up these sorts of statements. There's a very good reason for this - it's hard to determine what those numbers are! On the other hand, most CF developers would find their time very well spent if they focused more on optimizing database interactions and limited the amount of runtime work - the two biggest things that will make a meaningful difference in application performance. Most developers, even those who think they have, have not done this. There's a very good reason for this as well - it's harder than focusing on CF code minutia! > Also we shouldn't cater coding standards to the beginner, we > should train and assist the beginner to the standard. Standards are nice. The best thing about them is there are so many from which to choose! Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

