Positive Reinforcement in Code Reviews

Date Published: 21 March 2018

Positive Reinforcement in Code Reviews

Many developers dread reviews of their code, and one reason for this is probably that most reviewers only offer criticism rather than encouragement. Remember as a code reviewer that you can reinforce the things you see that are done well, which can be every bit as important and effective as nitpicking every style guide violation or misplaced bracket. Here are some actual comments I've left recently in GitHub pull reviews:

"Awesome name choice!"

"Yay! Getting rid of a magic value!"

"Deleting commented code - great!"

Anyone who has trained animals or attempted to train small children should recognize the value of positive reinforcement to encouraging desirable behavior (in one Big Bang Theory episode, Sheldon uses this technique to train Penny). It's an important thing to keep in mind, even if it doesn't come naturally. And you don't need to be "above" the other person in the org chart to offer positive reinforcement. Remember, code reviews are about the code, not the person, so when you see code that you like, make sure you call it out (and be specific about what you like about it). An easy way to get started is to try to add a single positive comment to each PR you review. You can make it a stretch goal to try to offer as much positive encouragement as you offer criticism. At the end of the day, you should strive to make others enjoy having you review their code, and one way to do that is to make them less depressing.

Great job! You read this whole post! You rock!

What can you do to be better about having your code reviewed? Check out The 10 Commandments of Navigating Code Reviews.

Steve Smith

About Ardalis

Software Architect

Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.