Code Style Guides - Consistency is King
- One minute - Jun 12, 2014
- #rant#design-patterns
There have been countless flame wars online about the details of the guidelines that appear in various Code Style Guides. Some of the most famous are the tabs versus spaces arguments, whether or not to put curly brackets {}
each on their own line, whether you should even use the curly brackets {}
for one line actions in if statements.
I am here to say that the only thing that matters in the style of your source code, other than syntactically correct code, is consistency. When a codebase has internal consistency, developers new to it are more easily able to pick up the meaning of the source code contained within instead of having to first understand why the different styles in different sections matter, or not.
The overwhelming rule that I try to follow when it comes to a style guide is that “the source code should look like a single developer wrote all of it” when in fact many developers have written different sections.