In Defense of Coding Standards

07 Feb 2019

Coding standards allow us to read code more efficiently and without having to stop every other line to understand what’s going on. There’s a feeling of uniformity and cleanliness with properly formatted code and even though it seems trivial to change code to “just make it look pretty”, following a standard can drastically increase a reader’s (and/or fellow programmer’s) comprehension.
Here are a few reasons why.

For your own sanity

Have you ever looked at some code and immediately feel your eyes glaze over with how hard it is to read? It could have random indentations everywhere, variable declarations that don’t make any sense, arbitrary new lines between statements and the worst part: there’s a bug you have to fix and it’s your code. Before you can even attempt to troubleshoot the problem, you first have to find the problem and in your code’s current state, that’s nearly impossible to do. Now, this whole thing could have gone much faster if you could actually read what was going on and streamline the troubleshooting process. No, it won’t solve the bug but doing this will sure help you find and correct it faster.

Others need to read it too

Now, let’s say you’ve spent a few hours looking at Stack Overflow posts and you still can’t fix your code. Therefore, you decide to go to ask your friend for help and it takes them a solid hour just to decipher what’s going on, let alone help with fixing it. Now, this is a good friend for helping you debug but imagine if you were to go to a professor for help or some other professional, someone who uses a coding standard. They will be far less inclined to help you out and far more inclined to shut your laptop and ask you to leave their office. Always assume that someone else is going to be looking at your code, even if it doesn’t compile.

Team effort, team standard

Let’s expand this hypothetical circle to include a bunch of people, all with their own pieces of the project to work on and they all depend on one another. If you can’t read what a function somebody else has written and you need it for your own section, you’ll either a) try to decipher their code or b) ask them about it directly, both of which are wastes of time. Instead, everyone on the team could follow a coding standard, easily read each other’s work, and finish your project with increased efficiency. Now you all look like a professional work force, fancy looking (and readable) code and all!