RDEL #49: What are common anti-patterns in code review comments?
This week we look at the prevalence and severity of various anti-patterns in code review comments.
Welcome back to Research-Driven Engineering Leadership. Each week, we pose an interesting topic in engineering leadership, and apply the latest research in the field to drive to an answer.
Code reviews are a very popular process on software development teams, and one that requires effective communication and collaboration techniques. This week we discover: what are the top anti-patterns in code review comments?
The context
Code reviews are a critical practice in software development, where developers systematically examine each other's code to identify defects, ensure code quality, and share knowledge. The main goals of code reviews are to catch defects early, improve code quality, and facilitate knowledge transfer among team members. This practice is widely adopted across both open-source and commercial projects due to its benefits in maintaining high code standards and facilitating team collaboration and knowledge sharing.
Despite their advantages, code reviews can present several challenges. The process involves technical scrutiny and human judgment, which can lead to inconsistencies, inefficiencies, and potential interpersonal conflicts. Code reviews are inherently a human-centric process, involving various technical, personal, and social dynamics that can complicate the review process and introduce inefficiencies.
We’ve previously reviewed research on what makes a code review useful, the gender disparity in code reviews, and the frequency/impact of destructive code reviews. This week, we’ll look more broadly at the main categories of anti-patterns in code review comments.
The research
Researchers explored the phenomenon of anti-patterns in Modern Code Reviews (MCRs), which are ineffective practices that recur and negatively impact the review process. The researchers aimed to identify and catalog common anti-patterns, describe their symptoms and causes, and understand their prevalence and impact on code quality and team dynamics. They conducted a detailed analysis of 100 code reviews from various OpenStack projects.
The study revealed several key anti-patterns and analyzed the occurrence of these anti-patterns in the MCR process. This included:
Confused Reviews (CR): Found in 21% of reviews, this anti-pattern occurs when reviewers are unclear about the rationale or details of a code change, leading to inefficiency and potential frustration.
Divergent Reviews (DR): Present in 20% of reviews, where conflicting opinions among reviewers slow down the integration process and may demotivate contributors.
Low Review Participation (LRP): The most common anti-pattern, affecting 32% of reviews, where there is insufficient reviewer involvement, increasing the likelihood of defects.
Shallow Review (SR): Detected in 14% of reviews, characterized by superficial comments focusing on minor issues rather than significant quality aspects.
Toxic Review (TR): The least frequent but most damaging, occurring in 5% of reviews, involving hostile or un-constructive feedback that can harm team morale and collaboration.
The application
The research findings highlight common pitfalls in the code review process that can hinder productivity and code quality. By actively identifying and mitigating these anti-patterns, teams can improve both the velocity of their development and the overall collaboration on the team.
To identify and improve code review practices on the team, consider these steps:
Create a Team Agreement: A team agreement for code reviews is a formal document that outlines the shared expectations, guidelines, and responsibilities for conducting code reviews within a development team. This structured approach can improve overall code quality, streamline the review process, and enhance team collaboration and morale.
Foster a Respectful Culture: Promote a culture of respectful and constructive communication to prevent toxic reviews and ensure that feedback is helpful and supportive.
Ensure Balanced Participation: Distribute review responsibilities evenly among team members to prevent low review participation and ensure that all code changes are adequately reviewed. It also increases the knowledge sharing across the team and ensures that the code review process and move forward effectively.
—
Wishing you a week of high-quality, effective code reviews. Happy Research Mondays!
Lizzie