Why Code Reviews?
Code reviews are incredibly important for many more reasons that you would first think.
In general, a code review is a common practice where one developer reviews another’s code to make sure it meets standards set by their company.
In this article, I’m going to run through all of the reasons why code reviews are so important! Why every developer, no matter how experienced or inexperienced should have their code reviewed and also perform code reviews themselves.
There are some great benefits to code reviews that you may not know about so let’s get into it!
First up we have a bunch of things to look for when performing code reviews and why they’re so useful.
The number 1 reason why people think code reviews should be performed is to get someone else to check your code to remove any errors that may be present. While this is the case performing code reviews isn’t going to remove all errors but rather reduce them. It’s not a one-stop-shop to make bug free code. Think of it like someone proofreading code looking for anything that could be misunderstood.
Code quality is another reason to perform code reviews. Checking quality means that a certain level of quality is met concerning basic programming standards. This is essentially the grammar of the code.
Looking for bad practices requires a more in-depth knowledge of what’s “Good” and what’s “Bad”. This is generally language-specific so for example with copywriting in Australia we spell the word “Specialised” with an “S” but in America, they spell it “Specialized” with a “Z”. There are many situations like that in code where neither way is wrong but one is better than the other.
This is fairly unique to coding and requires the comparison of business logic with code that’s been written. Maybe the code needs to check if someone is 18 years old or older but it’s only checking if they’re over 18.
Some companies are big with commenting, for others it’s hit or miss. In general, comments are there to make the code more easily understood and digested. Reviewing comments in line with what a company expects is essential and if there’s no guideline it’s worth remembering that they primarily come into play when making the code as readable as possible.
This is the last but certainly not the least bug related reason as to why code reviews should be performed. Programmers arguably spend more time reading code than writing it. This means that if the code is easy to read and understand then they’re going to get through this quicker leaving more time for code writing.
That’s all of the bug related reasons as to why it’s good to perform code reviews. Next up we have the juicy ones that most people never think about.
This is mostly for the code writer but also a little bit for the code reviewer. As a professional, if you know someone is going to be looking at the work you’re doing with a fine-tooth comb then you’re going to be more careful. You’re going to iron out your mistakes and hold yourself accountable. As a reviewer, while you’re reviewing someone else’s code you may be thinking about how or where you could be using their logic in something you’re writing. That brings us to knowledge sharing.
By allowing others to read through new code in bite-sized chunks means that the code is more digestible than if it was a complete program as they just get the code related to the new functionality. This means that the reader is getting the complete picture of how a piece of code has been implemented from start to finish. This is powerful information and can shape how they approach the same type of problem next time they run into it. If nothing else this is the single reason why you should be performing code reviews. If everyone is growing off each other then their skills are going to increase at an exponential rate compared to if they weren’t.
This means that the reader can get across the code that has been written so if or when they need to do any development with the software they are aware of how it’s already been written.
A team performing code reviews for each other builds a sense of teamwork and comradery as everyone feels responsible for all of the code that’s been written. A quick note that this can sometimes be taken too far if a reviewer is trying to morph someone’s code into their own, so it’s worth watching out for but still a very valuable reason to perform code reviews.
It saves time for everyone! It saves time on fixing bugs as the later in development a bug is found the longer it takes to fix. It saves time reading code by maintaining the code quality and whole team comprehensions of a codebase.
This covers all of the awesome reasons why code reviews should be performed!
For further explanation or help with code reviews, don’t hesitate to get in touch! I’m happy to help.