The many benefits of code reviews, and how to achieve them – 1. Introduction

25 January 2017, by

There is a lot of writing on the importance of code reviews and how to go about them at a low-level (i.e. what to look for in the code). This series of posts takes a higher-level look at how to approach code reviews and how to maximise their benefits. We’ll also refer throughout to other useful writing on code reviewing and how to make the most of it.

At Softwire, we have always carried out code reviews in one form or another. But our methods and tooling have evolved over time, and often varied between projects. This allows each project team to find a way of working that best suits them.

We recently ran couple of internal lunchtime discussion forums to talk about code reviewing and pool our collective experience. The goal here wasn’t to try and agree on “one true code review methodology”, but just to share ideas between teams. We discussed the perceived benefits and overall aims of code review, and how we go about achieving these.

It turned out that the approaches to code reviews within the company are even more varied than I’d thought. But there was some broad consensus on the benefits and aims of code reviews. However, the benefits that we valued most may surprise you.

What value do we get from code reviews?

Both of our discussions came up with a similar consensus on the range of benefits provided by code reviews. In rough order of their prominence in the discussions, these were:

  • Training and mentoring
    • In fact, several people felt that the healthiest approach to code reviewing was to treat it as a training opportunity first
  • Knowledge sharing
    • In both directions (i.e. both the developer and the reviewer had opportunities to learn from one another)
    • This includes sharing domain knowledge, general technical knowledge, and knowledge of the specific codebase
  • Encouraging people to produce better work (knowing that it will be scrutinised by your peers)
  • Keeping the codebase consistent, in terms of style and structure
  • More generally, keeping the codebase maintainable
  • Catching defects, or at least catching them earlier (and so making them cheaper to fix)

One point I found interesting here was that “catching defects” was one of the last points to come up, in both discussions. There was a lot more emphasis on the holistic benefits of code review: training, knowledge sharing, and improving the overall codebase.

Quality assurance is the main focus of some widely-referenced sources on code reviewing. For example, Jeff Atwood’s blog post Code Reviews: Just Do It, and the two books that it references (Peer Reviews in Software and Code Complete). These mainly focus on reducing errors/defects/bugs, and only briefly mention other benefits. Of course, improving defect detection is not a bad argument for doing code reviews. Perhaps it’s also the most persuasive one in organisations that don’t have a history of doing code reviews and are reluctant to let people start spending time on it.

Defect detection is a valuable and somewhat measurable benefit, which may make it a good angle to sell the idea of doing code reviews at all. However, for the developers and tech leads who actually carry out code review, it doesn’t need to be the only aim or even the primary aim of the exercise. So how do we go about code reviews at Softwire? We’ll cover this in the next post.

Tags: ,

Categories: Culture, Soft skills, Technical


Leave a Reply

* Mandatory fields

three + = 11

Submit Comment