Common Style Mistakes, Part 1
Subject:   style rules
Date:   2003-06-14 20:26:25
From:   johncogg
Response to: style rules

Although your solution is valid, it's also costly to have to needlessly include an additional file every single request. By simply using the standard
Regarding chaining function calls, yes my example was very obfuscated. However, I stand by the 3-parameter rule as a solid method of doing things. I do agree that as easily as there can be too many chained function calls, you can have too many temporary variables.. Also, although I cannot speak in regards to Lisp I must point out that in this case a comparison to C isn't valid. In C variables must be declared, etc. and perhaps in that situation can be more trouble than it's worth.. however in PHP, where variables can be created and assigned values without such hassle the impact is minimal.

Finally, regarding the ternary operator.. I again disagree. :) Since my arguments against this parallel those I have already made regarding chaining function calls inappropriately, I won't repeat them again.

Perhaps one style mistake that I should have made a point to bring up is that readability is extremely important. Without being able to quickly ascertain what is going on with a piece of code the chances of missing or not finding bugs is that much greater. If you claim that a piece of code is completely readable with 20 function calls chained together (as long as you indent it properly) then so be it :). However, as a general rule of thumb the techniques I have discussed in this column are extremely important and I stand by each of them :)

Thanks for your feedback.