Frontend Mayhem

Code Reviews: Why are they important?

July 18, 2016

pablo (3)

Code review, also known as peer review, is a highly beneficial practice intended to find mistakes overlooked in the development phase.

Code review is often associated with software quality but in this post we will look at the positive impact it can have on the company culture by promoting an open mindset, team work &  boosting conflict resolution skills.

How do code reviews work?

pullrequest1

Source: http://www.gulistanboylu.com/how-to-send-pull-request-on-github/

The concept is rather simple. A developer works on the branch of the software. Before his code is integrated into the master, another qualified developer must review the code and give it the “go ahead”. If the person reviewing the code has an issue, they’ll have a discussion until an agreement is reached.

Gotta catch ’em all

I just couldn’t resist that Pokémon pun!

The biggest argument in favour of code reviews is that they aid in catching bugs early. Although, that is true, I find automated tests to be much more effective to keep up the correctness of code over time.

So why should we do code reviews when we have unit tests?

The benefits of code reviews go deeper than just avoiding bugs.

Mindset

Developers tend to be very defensive about their code. Most of us aren’t always comfortable with others’ scrutinizing our code. This mindset is starting to change with the prevalence of open source development. However, majority of us are still uncomfortable exposing code to the eyes of the public.

“What if people think this code sucks?”

Code reviews can be a catalyst for developers to overcome this insecurity. They promote an open mindset within the development team. This mindset enforces the idea that all code is open to scrutiny from others. Developers must welcome scrutiny and not perceive it as a threat.

mindset-divide

Readability & Maintenance

The importance of code readability warrants a blog post of its own. I think it is one of, if not the most, important trait of a high quality software developer.

With a code review system in place, every line of code is written with readability in mind. Putting a well thought out and easy to read code in front of the reviewer becomes important.

If the reviewer can’t comprehend what a specific block of code does, consider one of the following options:

  1. Refactor the code to enhance its readability.
  2. Add a comment which explains what the code does.

Code that is easy to read & reason about can save hours of maintenance time. Rather than untangling the complicated mess that you or someone else wrote in the past, imagine being able to just go to work.

pablo (2)

Consistency

Every coding team has coding styles and standards set in place. As the code base & the team grows, maintaining the style can turn into a challenge. If every check-in (synonym with pull request) is reviewed by a senior engineer, the team is more likely to stay on course and produce consistent code throughout the project.

Soft skills

The act of resolving different perspectives is a challenging one and takes conflict resolution skills. A manager shouldn’t have to step in to resolve a standoff. The team should be able to rationally resolve internal conflicts without any supervision. Code review is a continuous process of conflict resolution, and provides your team with a perfect platform develop this pivotal skill.

An effective code review system will teach you to be receptive towards criticism and aid you in perfecting the ability to deliver harsh feedback in a respectful tone. Both improve your communication skill and are traits that will have a positive effect on the other aspects of your life as well.

Newbie friendly

Code reviews can also be extremely helpful for new team members. Through this process, they’re able to receive consistent feedback from their experienced counterparts & can quickly adopt the team’s coding standards. Code reviews can also empower new members as it provides them with a platform to question and/or discuss the standards put in place. If done right, code reviews can ease the transition of a new developer into the team.

In the end the team wins

It is the dream of a software development company to have a team which produces high quality readable code with consistent coding styles & standards. The team also doesn’t need to be babysit as it is capable of conflict resolution.

Does your team use code reviews? What other benefits do code reviews provide?


Watandeep Sekhon

Written by Watandeep Sekhon.
Website / Twitter / LinkedIn / Instagram