You are here

TL; DR. Coding standards are about more that the code on the screen, in the application. They are about culture, trust and collaboration. Smell and readability.

So, coding standards, fun topic eh. Arguing over tabs and spaces (check out Silicon Valley if you haven't already) for alignment of your code. It may seem like a bit of a petty idea to begin with. However, what I believe is that coding standards should give you better tools as a team to be able to collaborate. To share coding ideas easily and to quickly be able to trust new members or new projects.

I have an confession. I am a heavy user of tools to check my coding standards. I certainly do not write perfect code, or even remember all of the rules around the coding standards that I use. When switching between different PHP project, Drupal Standards, PSR2 Standards and such like, it is pretty difficult write poorly formatted code. So I use a PHP CodeSniffer and an integration with an IDE/Text Editor (Sublime Text 3 mainly) to make sure that my code is properly formatted.

So, what differences do we encounter?


if ($this = $that){
  $then = 0;


if ($this = $that)
    $then = 0;

One Line

if($this = $that){$then = 0;}

So, functionally these are all the same. They would all do the same job. However, we can all see that they are slightly different. Now if you extrapolation this to thousands of lines, or thousands of files. What you can understand is that you are going to end up with very different codebases. If everyone understands how to read the same code, you can easily fly through reading someone elses code, to find bugs or to fix issues.

However, standards only exist if you write them down and apply them completely. It is the cornerstone of being able to make readable and scalable code. If you are using a common coding standard, then you are able to much more easily adopt others code and work with it, or extend others code for your own requirements.

Code Smell vs Coding Standards

So, code smell. The insipid whiff of bad code. I have to make this plain, coding standards will not make bad code into good code. However, if you are writing in the same standards, then it becomes far easier to read or fix code, or even scan it and see errors or bad implementation quickly. Make decisions quickly and make then with the right information at your hands.

Repeating the TL; DR (Conclusion)

So, how really. Do code standards matter? Yes, but it is so you can easily work together. Not so you can bash others with arbitrary rules. They exist to allow you to work together with others and to be able to see and think similarly to other developers.