Some ColdFusion Development Best Practices

Community , Tips & Tricks , Tutorials Add comments
By: Luis Majano

We always are trying to help the ColdFusion community as much as we can.  We had a CFC best practices document in our ColdBox documentation site in order to steer developers in the right direction when building components.  I have updated the document to now include more topics than just CFCs.  So if you are interested in collaborating to this document or think some points are useless, please comment and we can make this document better.

So here are our ColdFusion Development Best Practices document: http://ortus.svnrepository.com/coldbox/trac.cgi/wiki/cbDevelopmentBestPractices

5 responses to “Some ColdFusion Development Best Practices”

  1. dickbob Says:
    Some interesting thoughts although you'll never get *everyone* to agree with *all* of them :-)

    It might be nice to include some justification to the reccomendations. For example I understand but don't like...

    <cfif len(firstName)></cfif>

    ...as len() doesn't return a boolean.

    Discuss...
  2. Peter Boughton Says:
    Heh, I haven't even got past the first screen, and I already disagree with half of it!

    The only one I'll explicitly state here is that "regex" is significantly more common (and less typing) than "regexp".
  3. Tony Garcia Says:
    I use code like

    <cfif len(firstName)></cfif>

    all the time. It's just shorter than writing

    <cfif len(firstName) gt 0></cfif>

    And the intent of the code is very clear to me. I'm not hung up on that len() doesn't return a boolean (even though it acts like it does), since CF is loosely typed anyway.

    I think a lof of these types of things just come down to personal preferences. The important thing is that you should have standard coding practices (whatever they may be) and stick to them.
  4. dickbob Says:
    @Tony - Be careful you don't end up on Sean's DNH list :-)

    From his "ColdFusion MX Coding Guidelines - Good Practice" doc http://livedocs.adobe.com/wtg/public/coding_standards/goodpractice.html he says "...don't rely on implicit conversions from numeric types to boolean".

    But you're right, it's a personal style thing and any standard is better than none.
  5. Tony Garcia Says:
    @dickbob
    Yikes! I'll try to be careful. Thanks for the heads up! ;-)

Leave a Reply