This is the fourth step towards gaining the Programming Enlightenment series. If you didn’t learn the third step, read it.
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand” ~ Martin Fowler
A greatly written code is a work of art. It’s as elegant as the masterpiece artwork of Van Gogh. These elegantly written code follows a standard known better as coding standard/conventions.
What is Coding Standard?
- These are set of guidelines that dictate how code must be written.
- The standard are different for every company, but a wide set of rules still apply to all.
- The guidelines include package structure, indentation, comments, docs, declarations statements, white spaces, naming conventions, programming practices, architectural patterns etc.
Why follow Coding Standard?
- Developers have their own way of writing code, having a coding standard allows for multiple developer to understand how the code is written.
- It helps in readability.
What are the different types of Coding Standard?
As far as Java developers are concerned, we have two industry standard
PS: For Android developers, they have Android Coding Standard as well.
How to enforce Coding Standard?
- Create a coding style and share among the team.
- Use various tool for static analysis of coding styles, such as checkstyle.
TL;DR Create a style file and share it among the team, thus creating same coding standard for the team.
Go to fifth step.
References:
- 97 things Every Programmer Should Know ~ Git Book
- 97 Things Every Programmer Should Know ~ Paperback
- How many lines of code programmer writes in a day ~ Quora
- Code Style ~ Tool
- List of code analysis tool ~ Wiki