Why Coding Standards Matter

David Mytton writes about coding standards on Sitepoint.


I completely agree.


Thus, it is natural that everybody wants their own habits turned into the standard, so they don’t have to change their habits. They’re used to reading code a certain way (their own way) and get irritated when they see code in a different format. The thing about defining a coding style standard is that there is no objective means by which to judge one style as “better” or “more-right” than another. Sure, we can talk about “readability” and “consistency” but what is readable is different for each coder (depending on what they’re used to) and consistency follows automatically because, well, why would you use another style?


The point of a coding style standard is not to say one style is objectively better than another in the sense of the specific details (75 character and one-true-brace convention, for example). Instead, the point is to set up known expectations on how code is going to look.

For example, look any PHP project written by more than one person. If you examine Script A and see one coding style, then examine Script B and see another, the effect is very jarring; they don’t look like they belong to the same project. Similarly, when Developer Joe (who uses one coding style) attempts to patch or add to a separate project from Developer Bill (who uses another coding style) the mix-and-match result in the same project (or even the same file!) is doubly jarring.

As PHP developers, we need to define and adhere to a coding style not because one is better than another but because we need a standard by which to collaborate. In that sense, coding style is very important; not for itself, but for the social effects generated by adherence to defined standards.

It is for this reason that I abandoned “my” coding style to adopt the PEAR coding standard. Sometimes you need to give up a small thing to gain a greater thing; by giving up my coding style, I had to change my habits; but now, anybody familiar with the PEAR standard can read my code and add to it in a recognizable way.

9 thoughts on “Why Coding Standards Matter

  1. I think I would fall into Harry’s group of it not being at the top of my list. However I think standard interfaces would help the PHP community a lot. I care less about capitalization or where the braces are, and more about consistent naming of core functions common across many libraries/classes. That incosistency has always been a weakness of PHP.

  2. Hi, Harry; hi, Chris,

    I agree that something like coding style is boring, as well as being an invitation to flamewar between “fanboys” of differing styles (as well as opening up a forum for “style Nazis” who have nothing better to do than point out where you used tabs instead of spaces ;-).

    I wouldn’t call it the top of my list, either, as far as style by itself is concerned. However, I would say that defining and then adhering to a coding style standard is one of the little things — even a foundational premise — that makes it easier and more enjoyable to collaborate on a project, especially when the coders themselves have only the Internet to communicate with (i.e., no face-to-face social environment to work in).

Leave a Reply

