Best Practices for Effective Code Reviews
By GITENTIAL TEAM
Before you start…
9 best practices for effective code reviews
Though it is “best practice” for everyone, regardless if they are senior developers and engineers to participate in code reviews, few have formal training in conducting them. Defining the code review process and standards is the first step.
But, what if your team hasn’t defined this a code review process or if your team is just starting up? It could be a good idea to get a copy of the Institute of Electrical and Electronics Engineers (IEEE) Standard for Software Reviews and Audits (IEEE 1028-2008). But, what if you don’t want to be that formal about it? The following best practices will go a long way toward bringing your team members to look forward to your code reviews, however often you conduct them.
1. Keep code reviews manageable.
2. Establish clear goals.
Write a description of what the code change is about and provide everyone a checklist in advance with an email, handout, whiteboard, or other collaborative tools your team uses. This identifies what you intend to cover and can help keep everyone on task. Address non-related issues separately.
3. Prevent disruptive and toxic behavior.
Include this as part of your checklist so everyone knows this upfront. You know your team members best, so if this is a regular occurrence, have a private talk with the likely offenders beforehand.
4. Have consistent scheduling.
Another best practice is to schedule code reviews the same time each day, or the same day and time each week. This helps to prevent scheduling conflicts arising with multiple team members.
5. Maximize participation.
Take into account the size of your team and office. Engage to include everyone, even if it means having multiple meetings (led by different facilitators). Each meeting is best limited to 7-10 participants to provide everyone a chance to be involved. No one should be exempt, not even the most senior developers and engineers.
6. Use code review tools.
7. Automate what you can.
Use automated code review and software development analytics like Gitential to accurately track your process improvement metrics.
8. Be constructive.
You are reviewing the code, not the coder. It is a best practice to give praise when the code conforms to standards, point out when it doesn’t. Praise effective solutions, offer better solutions and alternatives when they’re suboptimal. Take a moment to explain code defects and how they may impact other parts of the code.
9. Use records and reports.
IEEE 1028-2008 provides a comprehensive list of everything that should be recorded. At a minimum, keep a record of everyone who participated in the code review, when it was conducted, and the reasons why. This should also include a detailed list of what was reviewed, and what the results were (number of defects found and fixed, new solutions adopted, and other remedial, post-review, efforts to be taken).
Cost and ROI of effective code reviews
If you have spare time, Alejandro Lujan’s video provides a very good overview for software developers to do “Amazing Code Reviews: Creating a Superhero Collective” and was referenced in the betterDev Jan 27, 2020 newsletter.