Tech Blog

Coding Conventions free your mind

Posted At : August 22, 2006 9:45 PM

As a younger programmer I used to believe that I was too good a programmer to follow "silly" conventions and rules. I knew enough to be able to do it on my own.

As I have spent more and more time programming, and have had to go back an rewrite old code I've learned the hard way the programming conventions and guidelines are an absolute must.

As a wiser more seasoned (and humbler programmer) what I have realised is that they free your mind up from the petty decisions (what should I call this file?, should it be camelcase or underscore seperated?, should a form submit to itself or a another page? etc), and allow you to focus on the big decisions (is this application structured correctly, does it do what the end user needs etc).

A point worth making is that while many of the programming conventions that I now use are not inherently better than the other options (eg camelcase vs underscore seperated variable names) it's just that I do it consistently (and in a team everyone agree on them) and so the code is consistent and easy to read for everyone.

Another important guideline that we have concern where code should reside:

  • Core business logic - CFC's
  • Useful utilities and functions - CFC's
  • Any nasty hacks - CFC's
  • Display templates and HTML - CFM
  • Reuseable display templates - Imported CFM custom tags
or put another way, if you have to think (even for a second) about the logic in a cfm file then it should be encapsulated - into a CFC or customtag as relevant.

A good start for programming conventions for your team is ColdFusion MX Coding Guidelines by Sean Corfield

Cheers, Mark