By Elliot Orth
Why code reviews are needed and how they save time
Agile teams operate on the principle of self-organization, and the skill sets of different team members may overlap. This is partly achieved through code review. By performing code reviews, developers become familiar with the codebase and learn how to deal with new technologies and techniques that help develop their skills.
When a developer completes a task, another developer analyzes the resulting code, taking into account the following questions.
- Are there obvious logical errors in the code?
- Is the code fully usable for all the use cases described in the code requirements?
- Do the new automated tests cover the added code sufficiently? Do existing automated tests need to be rewritten to accommodate code changes?
- Does the code meet the requirements of the existing design guidelines?
Code reviews should be part of the team’s existing workflow. For example, if it’s customary for a team to create task branches, code review should begin after all the code has been written, automated tests have been run, and passed, but before the code is merged into the upstream branch. Then the person checking the code will be able to pay attention to those sections of the code that did not fall into the field of view of automation, and errors in the code will not fall into the main development branch.
How does an agile team benefit from code reviews?
Code review is useful for any team, no matter what development methodology they follow. For agile teams, it is especially useful because it helps to distribute work among different employees. No team member is the only expert on a particular piece of the codebase. Simply put, code reviews are a tool for sharing knowledge about the codebase among all team members.
Code Review Promotes Knowledge Sharing
At the heart of all Agile teams is unprecedented freedom of action, since all team members can take work from the backlog and perform it. As a result, teams storm into new work with great enthusiasm because the tasks are independent of each other. Generalists can work both on the client-side and the server-side.
Code review allows you to take breaks during work
No one wants to be the only person who can answer all questions about a piece of code. Also, no one is tempted to have to deal with a critical piece of code that someone else wrote, especially during an emergency in the production environment. Code reviews promote knowledge sharing across the team, so anyone can pick up the baton and move on. But the main benefit lies elsewhere: if more than one developer is involved in critical tasks, it means that all participants in the process can take breaks from work. If you feel like you’re being held hostage by source control, checking your code is a great way to find freedom. So you can go on a long-awaited vacation or devote time to another component of the product.
Code reviews enable the training of new specialists
Another distinguishing feature of agile is that when new members join the team, more experienced people become mentors. During code reviews, they discuss the codebase. Often, knowledge is hidden in the code that is unknown to the team. During the check, they are found. Beginners bring their fresh eyes and notice ugly, overlooked due to lack of time fragments of the codebase that need to be revisited. As you can see, through code review, new useful information is framed by existing knowledge.
Check before amalgamation
Mandatory review of the code before it is merged into the upstream branch ensures that unverified code does not enter the production environment. This means that controversial architectural decisions made at 2:00 a.m. and mistakes that an intern makes in using a design pattern will be caught before they can have long-term (and unfortunate) consequences for the application.