> Partly out of curiosity and partly out of need, I'm wondering
> whether anyone has any "ammunition" for discussions about best
> practices. For example, things like:
>
> 1. lock shared variables
> 2. prefix variables with a scope
> 3. select only columns you need instead of select *
> 4. cfscript is faster than multiple <cfset> statements when
> there's more than 3 etc.
>
> Granted, these are not hard and fast rules (except #1), but
> everyone seems to accept them as the best or proper way to do
> things. I hear many (and I do this as well) use the phrase,
> "according to Allaire...".
>
> Does anyone have any references that back things like this up?
> From Allaire, from personal experimentation, etc.? I'm looking
> for somewhat official information as opposed to "I tried this once
> and...". The kind of stuff you could bring into a meeting and
> hand out and people would accept, you know?
Unfortunately, things like this are never that easy.
First, best practices often encompass several goals. For example, you might
prefix variables with scopes to improve performance, or to ease maintenance
by improving readability. Sometimes, however, these goals may conflict; in
these cases, one person's (or one project's) "best practices" may differ
from another's. After all, if performance were our only measure, we'd do
everything in assembler.
Second, as a CF programmer, one needs to be competent in several areas: CF,
SQL, HTML, and others. So, a set of best practices used by CF developers
will also have to cover those areas. The SQL example you provide is
well-known in the world of SQL programmers, fortunately, so you don't really
need us to prove it for you.
Third, from a performance standpoint, many of the items of the kind on your
list are relatively trivial, when you come right down to it - they're the
equivalent of "how many angels can dance on the head of a pin?" Scope
prefixing and using CFSCRIPT for variable declarations fall into this
category. Neither one is going to make an appreciable difference in the
performance of your application. Is it better to use CFSCRIPT for variable
declarations? Is it a "best practice"? Not really, in any meaningful sense.
Personally, I tend to use CFSCRIPT for variable declarations, since I think
it slightly increases readability, but it's not really important to mention
in an application review. It's not going to meaningfully improve application
performance, and it's time better spent on other things rather than
rewriting these, given that we all have finite amounts of development time.
You might argue that, for future applications, you'd be better off doing it,
and therefore it is valuable, but its value is so small as to be nearly
immeasurable. I'd argue that it's more important, when concerned about
performance, to focus on the big things (well-thought-out SQL, for example,
or improving the flow of the application, or using caching), and the little
things will take care of themselves. From a best-practices perspective,
figuring out which things are worth looking at is itself important.
Finally, a lot of the performance "best practices" in the CF world are more
rational than empirical - that is, people think they make sense, but there
isn't sufficient testing to prove it.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.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