Code Review

In our daily tasks, designing, coding, and deploying are not the only things to do every day. There are also planning meetings and technical discussions to do with the other members and teams. And also code reviews (CRs). In this article, we will see what, why, how, and when to do code review.

Motivation

It is not about simply fixing errors in code but also to share knowledge and build common coding guidelines. Rather than looking for errors, you should review the code by trying to learn and understand it.

What Is a Code Review?

Code review is a methodical study of source code. It is dedicated to locate and repair errors missed in the initial development stage and to share knowledge and build common coding guidelines.

Roles and Responsibilities

  1. Developer/ Reviewee: the authors and the initiator of the review request/ merge request/ pull request.
  2. Reviewer: the people who will review the code and report the findings to the developer.

Why Code Reviews Are Important?

A delivered feature is the outcome of the collaboration of developers, architects, testers, ops guys, domain owners, etc. But the heart of the matter is the code because it translates the result of that collaboration for a customer request. So this phase can not be neglected like this. Indeed, it helps to keep a high quality of code with fewer bugs. Keeping that highness of quality helps to speed up the process from design to delivery. How? I’ll tell you.

[…] software testing alone has limited effectiveness. — Steve McConnell, Code Complete

In most organizations code reviews follow a rigid and formal process. Often, the reviewers are the architect or a lead developer. Reviewers require both the time to read the code and the time to keep up to date with all the details of the system and changes; they can quickly become the bottleneck in this process, and the process soon deteriorates which will cause sad customers at the end.

The Main Goals Of Code Reviews

The main purposes of code review are:

When to Code Review?

Have a regular code review day each week after automated checks (tests, style, other CI) have completed successfully. Spend a couple of hours in a review meeting or alone.

Review What?

The main areas a reviewer is focusing on are:

Tips for the Reviewee

When Submitting Code Reviews

The author is responsible for submitting CRs that are easy to review and not to waste reviewers’ time and motivation:

After/ During Code Review

Remember that the whole point of a review is to find problems, and problems will be found:

Tips for the Reviewer

Understand why the change is needed (fixes a bug, improves the user experience, refactors the existing code). Then:

Conclusion

We looked closer to the code review process. Code reviews play a key role when it comes to boosting efficiency and quality. Specifically, taking advantage of the right code review actions is what helps you to improve team members’ expertise first.