How To Build An Inclusive Code Review Culture

Photo by Lala Azizli on Unsplash

“… software testing alone has limited effectiveness — the average defect detection rate is only 25 percent for unit testing, 35 percent for function testing, and 45 percent for integration testing. In contrast, the average effectiveness of design and code inspections are 55 and 60 percent.” ~ Code Complete by Steve Mcconnell

What Is Code Review?

Code Review is a platform to increase quality and consistency in code by finding better solutions and increasing a sense of team solidarity. The overall goal is to gain a diversity of thoughts, which means Code Review isn’t just meant for developers. It is meant for everyone.

Why Is Code Review Important?

Code Reviewers bring fresh perspectives to the code. Here are the few that have benefited me greatly over the years.

  • The code reviewers can think of edge cases that you might not have thought through while writing the code
  • Being the builder of the code, you wouldn’t think of how to break a piece of code unlike the reviewers
  • If the reviewer doesn’t understand the code quickly, that’s your clue to realize that your code is too complex.

Common Misconceptions

  • Code Reviews can be overwhelming
  • They are time consuming
  • It creates an uneasy environment for author and reviewers

How to create a productive Code Review setting?

Before we lay these misconceptions to rest, here are some quick tips and tricks that have helped my teams over the years.

The author is the best person with a clear understanding of the requirements and the purpose of the code. Having the details in the merge request prior to the review sessions helps a lot.

Avoid the urge of pushing all changes at once. Reminds me of a tweet that I recently came across…

The Code Design and patterns are based on underlying software principles. They shouldn’t be weighed on personal opinions. So, making a collective decision on what is best for the product is ideal.

The Tough Reality

However, code review isn’t always sunshine and rainbows. It’s isn’t easy to have someone critique your code in front of your face. Likewise, as a reviewer, it can be tough to give someone raw, but helpful, thoughts on their code without feeling a tinge of awkwardness. These feelings are perfectly normal!

Code review is an incredibly powerful tool, and this part of the process is merely a small hump on the road to code heaven.

So, how can we create an inclusive environment that fosters the giving and acceptance of constructive criticism for the code review process? Here are a few helpful lessons I’ve learned over my career.

Avoid terms like mine vs yours. Avoid getting emotionally attached to your code.

We tend to think of our code like it’s our newborn baby. Obviously, no parent would want to hear someone else call their child an ugly baby. However, if we separate the idea of our code as our baby, it can be easier to process any criticism that the code will face.

As a product team, we can do a better job together in delivering a product than working individually.

Try to avoid comments like you should have used a constant. Rather, say something like it seems we need a constant because the value of this variable is static.

Try avoiding a tone like Rename this variable to "foo”. Rather, use What do you think of renaming this variable to "foo"?

Being an engineer and a mentor for many years now, I know for a fact that the coder tries their best before putting their code out for the world to see. It is always a safe bet to believe that they have tried everything to make their code the best it can be.

Here is a tip on how I had approached something when I didn’t like a coding pattern.

For example, instead of saying, Why didn't you use the base class here, I would try Have you considered using the base class or extending the class, that might help shorten your class structure?

Rome wasn’t built in a day! It takes time to know how to frame your words in a manner that will be helpful and pleasant sounding to the coder. Although difficult, giving constructive criticism is a valuable skill that will make your code reviews go smoothly.

Takeaways

I am confident that these tips and lessons will break the classic myths that are tied to the code review process. Adjust your styles to communicate during code reviews.

Lastly, Code Reviews are for everyone, not just developers. If you are not a developer and have made it this far, I encourage you to sit during the next code review. You will learn a lot about the internal system of a product.

Thanks for Reading!

It’s not easy to talk about coding in a way that will interest anyone other than your mother. I am a technical leader making an attempt to share my experiences.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store