I recently had the opportunity to work with some code developed by [NAME WITHHELD TO PROTECT THE INNOCENT] The code is absolutely great code, does some interesting things however…. it was just TOO well organized and way to verbose. Now normally if I’m going to criticize someone’s coding style, (which I generally do not do) it would be for the exact opposite reason as this. However this code was so well structured as to make it difficult to follow, and understand, much less fit on a screen.
Every argument for every CF tag began on it’s own line with every new tag separated by at least one line. Thus causing a single cffunction definition header (without any actual code in) to run to 40+ lines. As here
[VARIABLE AND METHOD NAMES HAVE BEEN MODIFIED IN THE FOLLOWING CODE TO PROTECT THE AUTHORS IDENTITY]
<cffunction
name=”functionName”
access=”public”
returntype=”any”
output=”false”
hint=”provides blah blah blah blah.”><!— Define arguments. —>
<cfargument
name=”Name”
type=”string”
required=”true”
hint=”some name.”
/><cfargument
name=”Type”
type=”string”
required=”true”
hint=”sometype.”
/><cfargument
name=”Location”
type=”string”
required=”false”
default=”here”
hint=”some location”
/>ETC…..
Additionally inside of a CFswitch statement … every case statement was preceded by the exact same comment and more than sufficiently spaced apart.
<cfswitch expression=”#whatsittype#”>
<cfcase value=”1″>
<!— exact same comment create a type of whatsit—>
<cfset scope.var = {
x = x,
y = y
} /></cfcase>
<cfcase value=”2″>
<!— exact same comment create a type of whatsit—>
<cfset scope.var = {
x = x,
y = y
z = z
} /></cfcase>
<cfcase value=”3″>
<!— exact same comment create a type of whatsit—>
<cfset scope.var = {
x = x,
b = b
e = e
z = z
} /></cfcase>
<cfcase value=”4″>
<!— exact same comment create a type of whatsit—>
<cfset scope.var = {
d = d,
y = y
z = z
} /></cfcase>
ETC….
Now don’t think that I believe that code needs to be short… I am a big fan of white space where needed… however if I need to scroll the screen to just read the method definition, there is a little too much verbosity in the code.
Coding is very much a matter of personal preference however when publishing code to the public it is generally accepted to follow some general guidelines on form. If you code in this style and share your code with the world… please take the time to condense your code prior to posting.
If you code in this style… why? What are your opinions on this coding style, is it helpful or does it make more work for the next programmer? What kind of style do you program in?