The Importance of Code Reviews

Developing software solutions is a process of mathematical repetition that is done in large teams of experts from a variety of backgrounds. That said, no matter how much experience they have, programmers are human–meaning, there’s always some chance that they’ll make a few mistakes here and there.

To get ahead of potential quality issues, programmers perform a systematic review of their source code to check for inconsistencies that can lead to bigger problems if left unchecked.
This process, known as code review, plays a critical role in the software development process and has become a defining principle of the Agile methodology.

In this article, we’ll explain the critical importance of code reviews and touch on some key best practices for making this process work in the context of Agile.

What is a Code Review?

Before we dig into the “why” behind code reviews, let’s take a moment to talk about the “what.”

Code reviews are a stage in the software development life cycle where programmers systematically check each other’s code for errors, irregular formatting, or inconsistencies with system requirements that may lead to bigger problems during software integration.

Generally speaking, the review process looks at four main areas:

1. Code issues

2. Consistency in formatting with the overall software design

3. Quality of documentation

4. Consistency with coding standards and project requirements

Code review first became standard practice in the 1970s when Michael Fagan began writing a series of journals for IBM on software inspections for Waterfall methodology. Fagan’s methods were known as the Fagan Inspection, where developers participated in a formal meeting with four major steps: initialization, preparation, meeting, and corrections.

While methods have evolved in response to changing technologies and development methodologies, the primary purpose of code reviews remain the same. The process creates a sense of collective ownership over the software’s progress through knowledge transfer by inspecting the source code as a team.

The standardization of code and formatting leads to a more accurate source code as a byproduct, but the overall goal is to keep the team involved in planning the later phases of development.

The Benefits of Code Reviews

Code reviews provide several key benefits, including:

  • Improves code quality–Code reviews improve code quality by detecting issues before they snowball out of control and ensuring consistent standards. This leads to robust software that is built from components for seamless integration and functionality.
  • Supports knowledge transfer–Source code that is constantly under review allows developers to learn more reliable techniques and best practices.
  • Helps teams create better documentation–Code reviews also help teams to create better documentation, which makes it easier for developers to add features and upgrade existing ones in the future.
  • Makes QA testing easier–Another benefit of maintaining consistent standards is a source code that is easier for specialists and testers to understand. In Quality Assurance (QA) testing, testers will not only have to check the quality of the code, they will also have to identify issues leading to poor tests. This can lead to persistent, avoidable delays in development due to further testing and reworking.

Although code review offers numerous benefits, it isn’t without its criticism. Some experts argue that code review isn’t compatible with Agile methodologies, though this opinion stems from a misunderstanding regarding how to effectively conduct the review process.

In these next few sections, we’ll go over some code review best practices that align with Agile’s iterative sprints without issue.

Code Review in Agile Methodologies

Code review plays a critical role in Agile due to the fact that the methodology prioritizes risk management. That said, some of the more traditional approaches to code review in direct conflict with the flexibility and informal, iterative nature of Agile development.

The “traditional” approach to code review is often a frustrating, inefficient process for developers–the original Fagan Inspection was a seven-step process involving three or four people. In it, each inspector would review the source code individually to look for errors and inconsistencies. Then, teams might hold a meeting to discuss the findings and share feedback.

While this mentality has persisted in legacy software development frameworks, teams following Agile methodologies take a more streamlined approach to code review, using less disruptive techniques like peer review and peer programming.

Here are a few examples of how teams can adapt their process around Agile best practices:

  • Skip the meeting. In Agile methodologies, teams often come together to discuss potential issues, inspect and question requirements, and transfer knowledge through collaboration.
  • However, post-review meetings are a productivity blocker and organizations should instead focus on developing a system that allows them to incorporate feedback throughout the coding process.
  • After errors are detected, a report should be sent directly to the author of the source code for corrections, saving time and effort.
  • Use peer code review and peer programming. Peer review consists of programmers exchanging code to be reviewed for feedback on their code and advice on next steps. This is similar to Fagan’s method without formal meetings, using e-mail, or simply visiting the programmer for quick solutions.
  • Peer programming is where two programmers work on the same lines of source code, with one programmer as the reader and the other as the author. This approach is more ad-hoc and informal than the Fagan Inspection and allows programmers to define the process that works best for them. Additionally, pair programming also supports knowledge transfer for highly complex coding projects or when a special skill is needed.
  • Use the right tools. Third-party collaboration tools can also make a huge difference–version control tools like GitHub, Visual Studio Code, and BitBucket, automated tools like ESLint & TSLint, collaboration platforms like Upsource support a more efficient code review workflow.

Final Thoughts

The code review process remains an essential stage in the software development life cycle, and while initially designed for Waterfall projects, code review has evolved in response to changing best practices. These days, peer reviews are a defining principle of Agile, playing a critical role in creating consistency in the source code and setting the stage for better QA testing and smoother integration.

By mitigating mistakes, programmers become more efficient in delivering high-value solutions to the client–on time and error-free.

Tiempo’s expert developers use Agile methodologies to deliver high-quality software that exceeds client expectations. For more information about how we make it happen, check out our
whitepaper about the Tiempo Quality System.

YouTube video