DEV Community

Cover image for Hacking Code Review: Give a compliment
Nick Holden
Nick Holden

Posted on • Updated on

Hacking Code Review: Give a compliment

This is part of Hacking Code Review, a series of bite-sized hacks you can start using today to make your code reviews more impactful. Subscribe to be the first to know about new hacks.

It’s easy to think of code review as an opportunity to find all the mistakes in a pull request. When I first look at proposed changes, I can be drawn to the code that’s most surprising or confusing, and it’s natural to begin thinking about what could be handled in a different way.

But if all your code reviews are exclusively critical, you could come off as hostile. Other developers may become frustrated and seek your feedback less often.

In your next code review, give the author a compliment about something you thought they did well.

When to give a compliment

One of the best times to give a compliment in code review is when you notice a novel approach. Authors tend to feel less confident about changes that don’t reuse a well-established pattern in the codebase, so when you see a positive change that looks different from what you’re used to, show your support. By giving a compliment, you send a signal that you’d like to see more changes like it in the future.

I know we usually stub this out, but your approach of calling the actual method in this test is 💯. I feel much more confident that we’ll catch changes to the API in the future. 😍

Another great time to give a compliment is when the author is a new contributor. This can be someone who is making their first pull request to a repository, but it could also be an author who is proposing changes outside their area of expertise. Giving a compliment to new contributors makes authors feel appreciated, and they’ll be more likely to contribute in the future. Having more developers comfortable contributing to more parts of the codebase leads to more resilient teams and software.

Love how you made this its own PR. I can see the temptation to group it with the rest of the changes that are coming to this model, but keeping this PR focused made it easy to follow and a joy to review. ✨

One other opportunity to give a compliment is when most of the rest of your review is critical. Don’t force compliments or try to maintain a certain ratio of positive to negative feedback—authors will notice when you’re not being authentic. Instead, compliment one specific thing about the change that you genuinely appreciate. A thoughtful compliment could help the author begin to think of ways to improve the rest of their proposed changes.

How to give a compliment

An impactful compliment is specific. If the compliment about a particular section of code, explain why you like it. Specific compliments help authors understand what they did well and what they may want to replicate in the future.

Woah, I had no idea that the old version of this scope wouldn't include records where type is nil. Great job thinking through edge cases!

Compliments of the change on the whole can be impactful, too. More meta feedback on things like impact, scope, or timing can show your appreciation for the author’s overall approach.

This refactor is awesome! I’ve been feeling pain working with this class lately, and this feels like the perfect time to make the arguments more straightforward. ❤️

Code reviews aren’t all about being critical, so next time, call out something you like about the author’s work. Everyone will feel great, and your review will be more impactful.

Cover image by Epic Fireworks on Flickr.

Top comments (0)