Everything to know about CODE REVIEW as a Beginner — Part 01

Priyanthini Sivasubramaniyam
5 min readFeb 23, 2023

--

What is a Code Review? And Why is it needed?

Photo by Alvaro Reyes on Unsplash

Code reviews also known as Peer reviews are the systematic validation processes of checking and reviewing the codes of each other in order to find bugs, logic mistakes, memory leaks etc. and thereby improve the quality of the code before merging or shipping it. The ultimate goal behind these code review processes is the code quality improvement.

Codes are developed by human, therefore there will always be possibilities for errors or bugs. So, once the developer completes his/her coding, it is always good and preferable to get the review or second opinion on that code before merging it into the main branch of the system code. A code reviewer can be anyone from any team or group who has a deep knowledge in the domain.

Many companies and project managers often neglect these code reviews which is a mere mistake. When you do the code reviews correctly, it will lead you to save more time, improve the code quality and accelerate the software development process. Other than that, people can save money by finding the bugs in their codes prior to implementing them. It is the most cost effective way of finding and solving bugs and issues in a code.

More than saving time and money, code reviews always help programmers and developers to build healthy relationships. This process paves way for the domain experts and the developers to interact and share knowledge among themselves. When one is pointing out your mistake in a more healthy way, you will start accepting the error and you will also get the chance to find the solution to eradicate that error with the help of that particular reviewer. Knowledge sharing will be merely improved through this code reviewing process. CEOs and Managers should admit that they will be having more collaborative and friendly teams when they start code reviewing processes in their companies.

These code reviews can be manual or automated (sometimes a mix of these two) and can be formal or informal depending on the situation, but anyhow at the end of each review, a review report (can be a list) will be generated with all the findings of the code review. More the reviewers, the more the quality of the solution.

In a report of research conducted by Stripe in partnership with Harris Poll, it is mentioned that on average developers spend over 17 hours per week dealing with maintenance issues like debugging and refactoring, and about a quarter of that time is spent fixing bad code. That’s nearly $300B in lost productivity every year. From this statistics you can clearly understand the importance of code reviews in organizations.

Pros and Cons of Code Reviews

The pros of conducting code reviews includes the following:

  • High quality code will be generated — a clean and concise code
  • Improved knowledge sharing within the organization
  • Improved code readability
  • Saves time and money
  • Enhanced collaboration among the co-workers
  • Enhanced security

The cons of conducting code reviews includes the following:

  • Can be time consuming particularly when it is a manual code review. Because there will be a need for the reviewer to go through the whole code manually which will surely consume more time.
  • Conflict of interest — preferences of different developers may differ in terms of coding styles, commenting etc.
  • Miscommunication might arise.
  • Might deviate the focus of the developers from other tasks or may be main tasks.

Are Code Review and Testing same?

A big NOOOOOOOO………..

Some people misunderstand that the code review and testing are the same. But that is not correct. Testing and Code review are two different validation processes.

  • Validation is a process of detecting the issues in a program to be more confident with the correctness of that particular program.

Okay let’s get back into our track, code review.

Common code reviewing approaches or methods.

Following are the main code reviewing approaches that I came across. If you know some other approaches please do comment below this article so that it will be helpful to me and several others.

  • Pair programming

Collaboration between two developers. One developer writes the code while the other developer reviews the code. This leads the two developers to quickly and efficiently solve the problems.

  • Over-the-shoulder reviews

This is also similar to the previous approach but here first the author of the code explains his or her solution and the reason for coming up with the solution and then the reviewer asks questions and provides suggestions on needed improvements. Author can make the small changes then and there during the discussion while noting down the larger changes to be done later.

  • Email pass around/ Email threads

In this approach, once a code is completed, it will be shared to the reviewer/s via email. Then the reviewer can share his or her suggestions through that email thread. This is preferred mostly for the small codes. Otherwise for larger pieces of code it will be really difficult to get the reviews through this email threads approach.

  • Tool assisted reviews

Here reviewing will be done with the assistance of a software tool. These tools help in overcoming the limitations in manual reviewing processes. Author will be notified about the new reviews which eradicates the needs for the direct meetings.

Code review best practices

There are a lot of best practices that can be followed in code reviewing processes. Some of the most common and important best practices areas follows:

  • Define the goals and standards of the review process
  • Limit the code review sessions to improve productivity
  • Use a code review checklist
  • Promote a positive and healthy code review process
  • Include everyone as much as you can in the review process
  • Adopt automated code reviews whenever needed

That brings the end of this article. If you really find this article useful, clap for it and share it as much as you can.

If you have any comments or points to add on to this article, please do comment.

The next part of this article on “Automated Code Review” is now available. Use the below link to check that too !!!

https://medium.com/@priyanthinisivasubramaniyam/automated-code-reviews-everything-to-know-about-code-review-as-a-beginner-part-2-74a839f4608a

Thank you.

--

--

Priyanthini Sivasubramaniyam

Assistant Lecturer, University of Colombo School of Computing. Writing on Software Engineering and Marketing related topics. Sometimes on self improvement :-D