Effective Code Review — The Human Aspect

swagata Acharyya
4 min readJun 7, 2023

--

Every developer has experienced it at some point in their career. The task of reviewing a peer’s code and the interpersonal challenges that arise during the process. Code review is important, and it has its benefits. An environment of providing and accepting constructive feedback improves the skill level of the whole team while improving the product.

However, the human aspect of the code review is often overlooked in different teams, resulting in unnecessary conflicts and negative outcomes.

Two canines reviewing each other’s code

Given its inherent complexities, how can we enhance the code review process and foster a positive and productive environment? Here are five tips that balance technical proficiency with emotional intelligence, improving code review quality while minimizing conflict.

Develop Shared Understanding:

Quite often, conflicts occur due to misunderstandings. The reviewer starts going through the changes without having the entire context. This way, the review becomes far from effective.

One way to handle this is to develop a shared understanding of the project goals and the purpose of the code review process. Before diving into the review, take a moment to discuss the objectives and scope of the code. Understand what the code is intended to do and how it contributes to the overall project. This mutual understanding will help ensure that the review stays focused and relevant.

Learning Mindset

Adopt a learning mindset when entering a code review. Remember, the goal is not to judge the author but to improve the code and promote learning. When both the reviewer and the author of the code embrace this mindset, the review process becomes a cooperative journey of learning rather than a battleground of egos.

None is perfect. There can be something in the code that can be improved. Similarly, there can be something in the code that can teach the reviewer a thing or two. A mind open to learning can help the product in the long run. At the end of the day, everyone wins.

Focus on Code, Not the Coder

To avoid personal conflicts, always ensure that feedback is about the code, not the coder. Comments like “You missed this edge case,” can feel accusatory and provoke defensiveness. Instead, frame your comments neutrally, focusing on the code: “This edge case might not be handled here.” This kind of feedback is objective, leaving no room for personal offense.

Try to refrain from expressing your personal feelings and focus only on the code. Things like “How could you miss such an obvious thing” will make things worse. Stay focused on the implementation and quality of code and don’t deviate.

Provide Examples and Be Specific

Nothing can be more frustrating than receiving vague feedback. It leaves the author confused and can lead to unnecessary conflicts. Always strive to be specific when providing feedback. If there is an issue, pinpoint exactly where and why it is a problem. Write meaningful comments to explain your view. Better yet, provide examples of how it can be improved. This clear and constructive feedback helps the author understand your viewpoint and encourages a positive response.

For example, statement like “This logic looks wrong” doesn’t do any good and leaves scope for further discussion. If the comment was given like this: “In this code you are dividing a by b and then subtracting c. According to the specification it should be b divided by a and then c subtracted from it”. This comment clearly mentions what’s wrong and how to correct it. People will see the mistake at the first go without holding anything against the reviewer.

Focus on Empathy

Empathy plays a very crucial role in code review. Remember, you’re not just reviewing code; you’re communicating with another human being who has invested time and effort into their work. It is just natural for them to be proud of their work. Show appreciation for their work and frame critiques as suggestions for improvement rather than direct orders. A little empathy can go a long way in maintaining harmony and fostering a constructive code review environment.

The art of code review is not just about technical know-how; it’s about balancing it with a keen understanding of human psychology. By developing a shared understanding, cultivating a learning mindset, focusing on the code, providing specific feedback, and practicing empathy, we can perform effective code reviews that enhance our code quality and maintain a positive, collaborative environment.

Remember, code review is not a battlefield, neither it is a place to establish supremacy. It’s a classroom, a workshop — a place where knowledge is shared, mistakes are learned from, and improvements are made. Reviewer or developer is not the primary focus. The center stage is reserved for the code, and by extension to the product. Leave it the way it is and things will be much more collision free.

How are you ensuring effective code review in your team? Let me know in the comments.

Happy reviewing!

Image generated with: https://gencraft.com/

Some portion of this article was researched with Generative AI

--

--

swagata Acharyya

Software Developer and Start up enthusiast. Working as an architect to build some cool product. Like writing code for mobile.