7 Steps to Keeping Your Emotions in Check during Code Reviews

Posted on 09/17/2020 by Ken Gregg

I have worked with a lot of software developers, many of whom have had several decades of experience, have been highly compensated, and have developed millions of lines of code for world-class products. And I’ve been involved in countless code reviews, both giving and receiving constructive feedback. Code reviews are an important part of improving the quality of software, as well as raising the team’s awareness and ability to generate readable, maintainable, reliable, scalable, extensible, portable, testable code. No matter how much software development experience you have, you and your code can benefit from the feedback generated in a code review.

Not once have I met even one software developer who has never made a mistake in their code, who hasn’t written a chunk of brittle code, who hasn’t written a chunk of code that is not scalable or extensible, or who hasn’t written a section of code that is difficult to read and maintain. This is just a fact of life. Years of experience doesn’t always translate to continuous improvement, and no one at any level of experience is always perfect.

The Problem

I occasionally encounter a developer who has several years of experience and who consistently becomes angry and defensive whenever anything in their source code is pointed out in a code review as needing improvement. This happens in live code review meetings, and virtual code reviews conducted through video conferencing or email. The negative emotions can have an immediate impact on everyone involved, and on the overall effectiveness of the code review process. It can actually shut down important feedback that is needed to improve the quality of the code and the product, and opportunities to learn and grow are diminished.

Here are seven steps to help you keep your emotions in check during a code review.

  1. Understand that developers are people, too.
    All software developers are people. All non-trivial software has bugs. All non-trivial source code can be improved. No matter how much experience you have, you are going to make mistakes of some kind, and you need to learn something or improve in some way. Experience, humility, and self-awareness should help you avoid repeating the same mistakes over and over, but there are always new mistakes to make.

    So, accepting this fact is a first step. If you believe it’s true, but don’t feel it applies to you, then you need to find a way to humble yourself into realizing that you are human, just like everyone else. Regardless of your level of experience, there is no getting around the “being human” thing. This is the first step.
  2. Depersonalize the feedback.
    Depersonalize it. I know many people have a tendency to think that they are what they do, what they create, and what they have. But your job, your work product, and your possessions are not who you are. All those things are a part of your life, certainly, but they are separate from who you are as a person. So, when someone is critical of your work, they are criticizing the work and not you. This realization can take some of the emotion out of the situation. It’s not you. It’s some code you wrote.
  3. Treat others the way you want to be treated.
    Be sure you’re treating others in the code reviews (and at all other times) fairly and professionally. If you’re not, it can have an effect on how they treat you. Even if they have a legitimate issue with your code, they might be tending toward making it feel personal, if that’s what you do when you have a legitimate issue with their code. Be nice. Play well with others. Be the type of person that others want to work with. In code reviews, take a constructive and helpful position when pointing out problems in other people’s code. This approach can go a long way toward them doing the same for your code.
  4. Be humble and open to learning.
    Years of experience mean absolutely nothing if you’re not humble and willing and able to learn from others and see things from other people’s perspective. If you believe you know it all, and there is nothing else to learn, your career is in big trouble. If you’re not constantly learning and honing your craft, you’re just running out the clock, and you’re falling behind. Learning never stops in this business, and learning requires humility, whether you have one decade or five decades of experience.
  5. Recognize you’re on the same team.
    You’re all on the same team. You have a common goal of creating a high-quality product that will have a long and useful life. Although a code review might seem like an adversarial situation, it is really about improving and learning. Have you ever had a bug filed against your code? Did you discover that it was a bug and fix it? The tester or fellow developer who found and reported the bug is not your adversary. They raised an issue, you fixed the problem, and the quality of the product was improved. You’re all part of the same team.
  6. Accept that everything can be improved.
    Sixth, there is always always always room for improvement, in everything. Take a look at some of the earliest non-trivial code you wrote. With an open mind and with your ego turned off, review that piece of code. Is there any room for improvement? Would you have done it differently today? If the answers are no, then either your ego is still engaged or perhaps you haven’t learned anything in the years since you wrote that code. If you’re coming up empty, show that old code to a trusted colleague, and see what they say about it. Now, consider that all the code you write today, if you look back on it ten years from now, will have something that needs to be improved. Code reviews just accelerate that process of improvement, by engaging multiple brains to look at the code.
  7. Gain control of your reaction.
    You can’t control what others do, but you can control your reactions. For many, however, this is easier said than done, and it can take a lot of effort and energy to change how you react.

    If you have trouble accepting constructive and reasonable criticism in this and other aspects of your life, and you can’t control your emotions in these situations, or you consistently become defensive and lash out at the source of the criticism, you may want to consider therapy. There is no shame in it. To be successful, you really need to be able to play well with others in this life, and that includes gracefully receiving criticism and learning from it.
code feedback constructive criticism effective code reviews experienced developers keeping emotions in check learning from code reviews software development software engineering programming best practice best practices code reviews source code reviews reviewing software source code