Skip to content

Coding standards

Coding standards determine the format of the source code, ie the typographic rules that must be followed when writing source code: white space, position of opening and closing braces, etc.

Why are coding standards important

You may have heard some developers say "As long as it works, who cares about the format of the code?".

This is a terribly misguided attitude. We developers spend far more time reading code than running it. As Eric Raymond said, we write code primarily for other developers.(source needed)"

Coding standards help make the source code more easily readable by other developers. In fact, it also makes your own code more readable to yourself.

More readable code wastes less time during code reviews, it facilitates understanding the logic of the code, and will help identify bugs more easily.

Good developers are good at coding standards

The skills required to follow coding standards are identical to some of the skills required to be a good developer:

  • Attention to detail
  • Self-discipline (to do the sometimes tedious parts of the work)
  • Ability to recognize and apply patterns

In addition, good developers always review their own code. To do so while checking the formatting for adherence to coding standards is both an application of this attitude and an opportunity to look at one's code with a different focus, thereby increasing the potential to spot bugs or logical inconsistencies.

Finally, good developers care about the readability of their code.

Coding standards are arbitrary conventions

Discussions about the respective merits of indentations as spaces or indentations as tabs are a pointless waste of time. All coding standards are ultimately somewhat arbitrary.

What matters is consistency. What slows down the reading of the code is variations in the formatting, e.g. inconsistent indentations, inconsistent positions of opening braces, etc.

Coding standards vary by language. Some languages have an "official" style guide (eg PHP, python, Java, Dart). Javascript has multiple standards.

"Official" or semi-official coding standards may be overridden or amended by a company, for a project, for a number of reasons.

Whatever the coding standards adopted, they should apply across all the code, at the very least in the same source code file, but also within an app; ideally across all the apps in a single project; and where possible, across a whole company.

Common Coding standards

Language Standards
Dart Effective Dart: Style
Java Google's Java style guide
Javascript AirBnb, standardjs
PHP PSR-1, PSR-4 and PSR-12
Python PEP 8 -- Style guide for Python Code

Your responsibilities as a developer

As a developer, it is your responsibility to:

  • When you join a project or a team, identify the applicable coding standards, as decided by the team for that project, for all the programming languages in use.
  • If there are no defined coding standards, propose some to your supervisor (keeping the customer's technical person, if there is one, in the loop).
  • Follow the selected coding standards.
  • Configure your IDE's linting tools according to these coding standards.
  • Lint your code before committing.

Linting tools

There are plenty of linting tools to verify your code's adherence to coding standards, and even fix most of the errors found.

Most IDEs include tools to do this in real time as you type the code.

These linting tools can be configured to match exactly the coding standards applicable for your project.

This means that there is no excuse for committing non-standard code.


Always lint your code before committing.