What is a Code Review?
Also known as peer code review or peer review, code review is the act of purposely collaborating with fellow programmers through reading, understanding, discussing, and fail-proofing code bases.
The primary mission of code review is to make sure that the overall code health is maintained and improved over time. When done correctly, it provides several benefits: streamlining the development process, reducing the amount of work required in Quality Assurance, and often enough identifying bugs that can go undetected in testing.
As the following graph shows, when organizations were questioned about what made the most significant impact on code quality, performing effective code reviews got the highest praise for improving the overall code and enhancing the product quality.
* Survey on a team of 680 developers. Source: The Ultimate Guide to Code Reviews for the anxious VPs of Engineering. https://www.codacy.com/ebooks/guide-to-code-reviews-I
Types of Code Review
Tool Based – implies using a specialized tool to facilitate the code review process and has become increasingly popular because of some notable advantages: displaying changed files in an organized manner, mediating the dialogue between reviewers and developers, and providing valuable metrics on the efficacy of the code review process.
Ad Hoc – or over-the-shoulder review is the oldest and most intuitive way to engage in peer code; it refers to the more “informal” and lightweight approach when an experienced team member goes through the new code, providing feedback while discussing it.
Meeting Based – this approach implies a series of meetings: an introductory session for presenting materials and setting objectives for the review, followed by an inspection meeting where materials are reviewed, defects are found, and metrics are collected manually. Currently, it’s probably the least popular due to time consciousness and the rising traction of tool-assisted tools.
Artifacts to Review
While some particularities depend on the project, the essential premise of any code review is that technical facts and data overrule opinions and personal preferences.
Here is a list of aspects that reviewers take into account during the code review:
- Compliance with task requirements
- Functionality
- Complexity
- Naming
- Comments
- Style
- Consistency
- Necessary updates to the documentation
- Test Cases
Keys to Code Review
The code review process should not be viewed as a one-sided system. On the contrary, constructive feedback and exchange of ideas can definitely build a better team and improve the overall coding skills of its members.
When it comes to developers, here are three important things to acknowledge:
- Check your work before submitting it for review
- Make sure the code complies with all the guidelines
- Don’t take the feedback personally
Golden rules for reviews:
- Give constructive feedback and explain your reasoning
- Be conscious of tone – educate, don’t criticize!
- Learn together by sharing your knowledge and empowering others to share their thought process
Stay tuned for more technical details. In our next article, we will reveal some tips & tricks that can make code review easier.