DEV Community

Cover image for Mastering Code Reviews: The Ultimate How-To Series
Nemwel Boniface
Nemwel Boniface

Posted on

Mastering Code Reviews: The Ultimate How-To Series

Introduction

Hello friends!

Welcome to the first part of the Mastering Code Reviews: The Ultimate How-To Series

Picture this, assigned a certain amount of features to implement. how will you know that the code submitted by them is functioning according to the given project requirements? You check it! This is where the code review process kicks in.

This will be a multiple series where I aim to teach you all you need to know about code reviewing. In this article, I will teach you what we mean by code review, why code review is important, what are the qualities of a good code review, what makes up a good code reviewer, list down some drawbacks associated with the code review process, and wrap it up with a conclusion. In a later article, I will do a hands-on tutorial on how to make use of the GitHub review features available to perform a code review.

At the end of the series, you will be more equipped to start making reviews for your peers and add code reviewing as a skill under your belt.

Sounds interesting right? Let's dive straight in!

What do we mean by Code review?

Code review in software engineering means the systematic, collaborative, and iterative process in which one or more developers examine code written by team members scanning for errors in the code to assess whether that submitted code does exactly what it is supposed to do as per the provided project requirements.

Wondering what we mean by the code review process

Code review is collaborative since it involves at least two people, the author of the code and another person who reviews the code. It is systematic since to perform a meaningful code review, there needs to be a set standard followed to approach the code review process. It is also iterative since if there are errors found, the code will be sent back for revisions and when done put back into review. This process is repeated until the code satisfies the provided project requirements.

Why is the code review process important?

Code review is one of the most important steps in the software development lifecycle. So what are the advantages that you will accrue from doing code reviews?

  1. For your junior developers in your team, code review facilitates the transfer of knowledge and helps them to learn faster. This is because as they collaboratively receive feedback on their code from their peers or the seniors, they can learn new ways of doing something or why implementing features differently is better.
  2. It serves as a bug detection avenue that might have been missed by the written tests for the project. This is because the code reviewer will generally be someone who is knowledgeable and has some understanding of the future implications of not re-writing a code block and rectifying it during the code review process.
  3. We often have the "Make it work optimize later". Code review helps to eliminate code that is unreadable or unnecessarily complex making it unmaintainable. It is here where that complex code will be rewritten when you are provided with suggestions of how to better approach an issue. This will in turn make the code readerable and maintainable.
  4. Code review ensures consistency of the whole code base. This is because different organizations have different ways in which they structure their code. This is always enforced during the code review process where any code that is not up to the company's standard is returned to the author and changes are required.
  5. Code review enhances the interaction and collaboration of the different team members. This is because different people might be the ones to review your code and in this way, you get to interact with different people within the organization.

What are the qualities of a good code review?

We have to acknowledge that anyone can give a code review. However, we have to ask ourselves, was the review given of quality? Below are some of the pointers for a good code review:

  1. One that is provided promptly. It would not be good if you had to wait for a long time to receive a review of your code. Remember that time is of the essence when creating software and you would be required to also start working on another feature which requires that this feature be approved.
  2. One that is thorough and does not miss some of the important aspects. It would hurt if you received few changes to make in the first review and when you submit your code for a re-review, the code reviewer introduces new issues that were not mentioned in the first review. One that is constructive and does not deviate from the project requirements. The reviewer needs to raise issues in the code that are actionable and not guessed issues.
  3. One that uses respective language and tone and acknowledges your efforts so far. We all make mistakes and the best you can do is to be respectful to someone when you are suggesting changes. This would make the one who is to make the changes respected and acknowledged and will make the changes with enthusiasm.
  4. One that offers a learning opportunity. This depends on the kind of changes that will be requested and the approach that will be used by the reviewer which will either help the junior developer learn by offering constructive feedback or break them by adding unrealistic changes to be made.

What makes up a good code reviewer?

We can all see why code reviews are very important and by now, you might be itching to get your hands dirty reviewing your friend's code. But wait! Do you have the qualities required to become a good code reviewer? Let's see if you possess any of the below qualities. A good code reviewer is one who:

  1. Has strong communication skills. Remember that when performing a code review, you will be explaining to someone, "This code is great, but it has some issues. Here is a suggested way to fix it, and here is why you should consider making this change".
  2. Has a strong technical understanding of the underlying technologies being used. You cannot make a code review for something that you do not understand and this is why to become a good code reviewer, you need to have mastery of the underlying technologies to be used.
  3. Is empathetic and patient. The truth is making changes to your code is hard. Most of the time, the author might not be able to implement exactly how it is supposed to be implemented and this is where being empathetic and patient comes into play. You will be better able to accommodate everyone even the least experienced developers in your team.
  4. Is one who can think critically. Making a code review involves assessing the code. It is up to you as the code reviewer to assess whether this submitted code is optimum or might require changes. This is where the skill of critical thinking comes into play.

What are some drawbacks associated with the code review process?

While it is evident that the code review process does have many advantages, it is not always bliss, and like everything, there are drawbacks related to performing code reviews. They include:

  1. Sometimes the code review process can be very time-consuming. This is based on the fact that there could be multiple revisions which take time to both implement changes and re-review.
  2. The code review process could lead to conflicts between team members. When one of the team members feels that the other party is intentionally requesting changes even though the project works perfectly fine that could lead to a lot of conflicts between team members.
  3. Sometimes the code review process could be subjective and might not be objective. Remember that the code review process relies on what someone thinks about a specific code and might not be as objective as someone would want it to be.
  4. With the possibility of making numerous revisions of the code, this would significantly slow down the development lifecycle making it take longer to implement features than they should have taken. This has a direct effect on cost since the longer a project takes to be completed the higher the cost involved in its development.

Conclusion.

From my discussion above, we can see why code reviews are important. We also flipped the other side of the coin and saw the cons that come with the code review process. Would you be willing to do a code review for your peer or suggest it to your team members? Please let me know in the comments section bel

This brings us to the end of the first part of this series. After reading this article, are you able to define what code review is, what are the advantages of performing code reviews, how you can distinguish whether the code review you received was good or not, and for those who are already excited about code reviews, the qualities that would help make them good code reviewers?

Part B of this series will include a practical tutorial teaching you how to perform reviews making use of the GitHub review features. Stay tuned!

If you read till this point, I send a big thank you.

I thank my readers for reading this far

That is it for today's class. I hope this was useful information for you. See you in my next article.

Top comments (0)