Coding Convention: Why your team should adopt one quickly

Tags: codequality, convention, career, software
Published: 2020-07-16 16:21:30

Your team needs to adopt its coding convention and do it quickly. This is a case of either do it or suffer the consequences.

I am sure you have seen various arguments on issues like **tab and space, snake_case and camelCase (DB related),  naming convention, etc** all these and many more are issues you will eventually have to address whether early on by adopting a team coding convention that will serve as a guide and ensure that everyone can sleep well at night or later on in the development stage where you have to do some tear-down and re-building because you have failed to address an important issue early on.

### <u>What is coding convention?</u>
These are sets of guidelines adopted by a software development team which enables the team to write consistent and easy to understand code by all team members. Usually, a team’s coding convention is a set of guidelines which is a document that guides not just how variables and methods should be named or the number of spaces that make a tab but which can also include the overall structure of the code and choice of design pattern used.

Notice that I called it adopted because, in many cases, you will not have to define all these guidelines from scratch but rather use one or a mix of the existing conventions in your team.

### <u>A note on best practice</u>
The fact that various best practices at best are silent on some salient issues, then your team needs to develop exactly what is best for it.

> <i>Nothing is best about best practices if it does not benefit your team</i>

### <u>Why your team should adopt one fast</u>
Adopted team coding convention ensures that the team writes consistent code which means that there will be less back and forth among team members about code clarity.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/gzzwd2tfnnixqa40vy7s.png)
[Image source](https://vegaskid.net/2017/08/writing-good-code-101/)

**It helps new team members onboard quickly** because they can always have some sort of guide while looking at your codebase in a bid to understand it to be able to add valuable contributions thereby reducing the Turn around Time for delivery and increasing throughput.

**It helps in code maintenance**. Having uniformity in codebase helps because everyone understands exactly where to find various pieces of code across the codebase and this helps greatly in maintenance.

**Faster debugging**. When you know where to find what, part of the problems is solved while debugging since you won’t have to start troubleshooting to know the exact location of various files/code in the codebase because there’s a certain way that your code is structured which is clear to all team members.

> In general, adopting a team coding convention/guideline early on in the development process helps the team to work more efficiently than when each team members have their different styles which can lead to a problem when trying to integrate various parts of the codebase.

### <u>The chaos to expect if you fail to do so.</u>
At best, you are the only developer in your team and you hope to leave as soon as the team starts to expand, by that, new developer team members won’t have your head 😂

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vmsbqt8y9y4b159t2arx.png)
[Image source](https://xkcd.com/1926/)

Not having or adopting a particular coding convention for your team will lead to delay in development time because part of the time will be spent on arguing what is actually best from individual perspectives while in reality most of these things are really just based on preferences.

**Debugging nightmare**
Because you are not exactly sure how the other team member has structured his or her code, so much time can be wasted trying to find where various files are in order to be able to use them in debugging.

### <u>Useful Tools</u>
Here are some nice open-source tools that can help in enforcing team coding convention. Although it may seem a little not convenient at first, it will be a great time saver in the long run.

#### Linters: ESLint (JavaScript)
You can find various linters for your equivalent programming languages, they practically do the same thing. If you would like to know how linter works check [here](https://en.wikipedia.org/wiki/Lint_(software))

#### Style guides: (Airbnb - JavaScript, PEP 8 - Python, Google Java style guide - Java)
These are predefined guides that you can adopt for your team and integrate with your linter to the hard work of ensuring every line of code adheres to your adopted team’s coding convention.

> <i>In conclusion, whether you choose to address the issue of coding convention early on in the development stage or you leave it to chance and at the mercy of individual team members, one thing is sure, you will still have to address it at some point in your development journey and one will be costly while doing it at the early stage will be beneficial to all.</i>