Use consistent coding conventions, automatically enforced
Code should be formatted the same way and enforced automatically using tools.
Why
- Code is read much more often than it is written. The more familiar the conventions the less time is spent on code reviews, visual parsing and code comprehension.
- Code conventions are learned quickly. Automatic enforcement exposes the developer repeatedly to the same errors making learning comfortable and at their own pace.
- Less mistakes. Code errors are raised straight away. In some cases they are fixed automatically.
- Constrains choices. More focus on engineering problems rather than distracted by inconsistent code or uncommon language features.
- Reduces conflict. Minor decisions, such as spacing and formatting, no longer need to be debated.
How
- Use a static language to prevent errors.
- Use a linter (e.g. eslint, python) or formatter (e.g. gofmt) to enforce standards.
- Adhere to common language conventions or standards (e.g. Python's pep8).
- In languages where a common convention hasn't been decided. Opt for popular third party configurations. There will be a higher chance that this will make third party libraries easier to read and the rules can be reduced to suit the teams preferences.
- Link tools to IDE/Editor for rapid feedback.