Every code review has a silver lining

5 ways to find positive things in code reviews

Gabriela Motroc
code reviews

Friends bullying to a sad boy image via Shutterstock

One could argue that there’s no nice way to handle code reviews since the whole idea is to find flaws but this doesn’t mean that you cannot handle this issue with care. You might think that you need to scrape the bottom of a barrel to find some positive aspects of code reviews but it’s really not true. Here are some positive ways to point out the flaws in one’s code.

Telling someone that their code is not good enough may trigger undesired animosity between the defendant and the plaintiff, which is why developers have mixed feelings about code reviews (no matter if they are the ones reviewing or being reviewed). According to Atlassian, code reviews make for better estimates, they enable time off and newer engineers. However, one cannot ignore one of the biggest downsides of code reviews —they make developers vulnerable.

So the question remains: how do you tell a developer that their code is not so good without hurting their ego? We found the answer to this question on Stack Exchange and Quora.

Criticize the code, NOT the author

One popular opinion is to criticize the code and not the author. It’s better not to use the words “you” or “I” —instead, use “the” or “a” to talk about code and keep it impersonal. Again, a person whose code is being reviewed is vulnerable and talking about “their” code instead of “the” code will just make matters worse.

It’s the tone that makes the music

If you are talking to them in person, you should know that your tone (and body language, for that matter) matters. You don’t want to accidentally dismiss their skills and you surely don’t want to act superior, no matter the type of mistake they did. As we mentioned earlier, code reviews are (obviously) all about finding the flaws but they should not transform into a witch hunt. So tone down your voice and attitude and present strong arguments to make them understand why the quality of their code is poor.

Write down the rules for passing a code review

One of the people who commented on this matter opined that code review will not be like walking on eggshells if there are clear rules for passing a code review. If the developer does not agree with your comments, all you need to do is show them the rules. Although it’s not ideal to hide behind a list of dos and don’ts, the only thing you will be guilty of is checking if the rules have been followed.

Allow them to get even

It’s not always possible to stop them from hating you if you criticize their code but what you can do is give them the chance to get even. This is not exactly healthy but if you allow developers to review each other’s code (but ask specific questions, moderate this whole experiment), they might learn something from each other. One thing is sure — they will bend over backwards to point out others’ flaws but if you convince them to say exactly how they would improve the code, this attempt will turn into a team exercise and not a vengeful, adversarial one.

Be proactive — give constructive criticism

There are ways to communicate bad news professionally but chances are that the person who reviews developers’ code will not use them. What the reviewer needs to do is offer answers to the following questions: What’s wrong with the code? How can the developer make it better?

Make sure they know that your door is always open if they have further questions or comments and offer them the option to review the code privately.

If this doesn’t work, use biometrics to measure code quality.  Sebastian C Müller and Thomas Fritz from the University of Zurich, Switzerland acknowledged that relying on code review is “a common industrial practice to identify code quality concerns,” but warned that this method has two major flaws: it is costly and it only takes place after a code change is already completed.

The researchers used Ward Cunningham’s quote “every minute spent on not-quite-right code counts as interest on that debt” to emphasize that “delaying software quality concerns [defects or poor understandability of the code] increases the cost of fixing them.” Müller and Fritz’s goal is to use biometric sensing to overcome these disadvantages and lower the development cost by identifying code quality concerns online while the developer is still working on the code.

The results show that biometrics helped to automatically detect 50% of the bugs found in code reviews and outperformed traditional metrics in predicting all quality concerns found in code reviews.

Although the paper shows the benefits of using biometrics to measure code quality, it also notes the privacy concerns. The researchers claim that “more research is needed to investigate a feasible solution.”

Gabriela Motroc
Gabriela Motroc is editor of and JAX Magazine. Before working at Software & Support Media Group, she studied International Communication Management at the Hague University of Applied Sciences.

Leave a Reply

Be the First to Comment!

Notify of