Software is written by human beings, so it is logical that it should contain errors. Software developers use manual or automated tests to detect them, but there is a resource that is sometimes overlooked: the ability to see and correct errors by ourselves.
Of course, it is quite difficult to detect an error in our own work but, what if we have our code reviewed by a programmer of our same (or higher) level of experience?
Thus, Code Review, or Peer Code Review is the act of knowingly and systematically having other programmers to check for errors in our code. This practice has been shown to speed up and streamline the software development process.
Code review: an introduction
Code review as a concept emerged in 1976, with the article “Design and Code Inspections to Reduce Errors in Program Development” by Michael Fagan.
Well-executed Peer Code Reviews save time and speed up the development process, reducing the amount of work required by the Quality Assurance team. It also saves money, as it detects errors that go unnoticed in tests and then appear to the chagrin of end users.
Additionally, peer code reviews bring the added benefit of building friendship and camaraderie among team developers and spreading the code’s “ownership” sense. Younger programmers also gain experience when their code is reviewed by more experienced programmers.
Code reviews not only detect problems: it allows for cleaner code, solving common problems and identifying many issues such as memory leaks, buffer overflows, or scalability bottle-necks.
Various methods and approaches
Code review has evolved nowadays from a group of programmers stuffed in one room to much more sophisticated organizational systems:
Email Thread review
As a portion of the code is ready, it is emailed to the reviewers as a file that is reviewed by each peer when their workload allows it. This system is flexible and adaptable, and generates a series of opinions and suggestions that the original programmer has to arrange and incorporate into his coding.
Pair Programming & review
In this approach, software developers work side by side on the code, checking their partner’s coding at the same time. It is very good for novice programmers to work with more experienced ones. Although widely used, it has the disadvantage that it uses more resources in terms of time and personnel than other methods.
Over the shoulder review
More comfortable for many than Pair Programming, the over-the-shoulder review is one of the oldest and most widely used forms of code review. For it, the programmer looks for a reviewer as soon as the code is finished, and then both discuss the logic behind each part of the program.
In this modern method, the code is reviewed through tools integrated into standard IDE and SCM development frameworks. These tools resolve many of the limitations of the previous approaches, as they allow tracing the comments and proposed solutions in a clearer, more coherent way.
This method enables asynchronous and outsourced reviews, without unnecessary meetings. There is also a trace of the reviews that allows statistical analysis and audits to improve the review process and generate quality reports.
Whichever peer review method is used, code review is an important component of the Quality Assurance plan of any software production team. The Peer Code Review eradicates errors just before they appear, and even prevents future product evolution issues.