Ask HN: How do I avoid coming off as harsh during code reviews?

2 points by finaliteration ↗ HN
I'm a senior developer on a team with 3 other junior developers. Before I joined the team, they weren't doing any sort of code reviews/pull requests and I recently implemented a process for submitting pull requests and getting approvals, etc, before merging and building.

My problem, however, is that I feel like I come off too harsh when I make comments on pull requests. I don't ever launch into personal attacks, but I do tend to keep my comments pretty matter-of-fact or dryly suggestion-based ("Our style guide says X", "I think it's better if we do X here", "Class names should start with an uppercase letter", "What if we use X here?"). It's not that my comments feel mean or hurtful, but more that they possibly lack empathy? Also, no one has said that I come off as harsh, I'm just pre-empting any issues because I know how much I hate working with people who seem hypercritical or tone-deaf.

Or maybe comments like those are totally fine and I'm overthinking this?

5 comments

[ 5.2 ms ] story [ 15.5 ms ] thread
You could try what's called a "sandwich technique" where you preface and follow your constructive criticism with positive feedback. A highly exaggerated example could be: "Your code shows amazing creativity and imagination -- I like that! But this section isn't as efficient as it could be; in fact, using a common algorithm -- like the one I'll send you by email in a moment -- you could speed up this function 3200x. You've got great passion and insights -- keep up the great work!"
Interesting thought! What about if there's not really anything there to "praise", but it's just a chunk of code with some things that are off?
Have a conversation. As a code reviewer you're looking to increase the understanding of the person whose code you're reviewing -- which starts with understanding why they wrote the code they way they did. Some people simply understand things differently and what's intuitive to them isn't to others. Consider the code sample I talk about in the following blog post: the only thing that's "wrong" about it is that it's probably not obvious to anyone other than the author.

URL: http://www.mikece.com/2015/08/clean-code-vs-really-clever-co...

I think you are doing great! It is hard to convey empathy with comments. As long as your interpersonal relationship with the junior developers is fine, I wouldn't worry too much about it.
Thanks! I just don't want anyone to think I'm being critical of them as a person. My main goal is to share and help the less experienced folks learn. It's just hard to do via PR comments where there really isn't a whole lot of opportunity for touchy-feely stuff.