Discussion summary

Discussions about code review highlight its multiple purposes, including maintaining code quality, preventing overly complex code, and oversight by senior engineers. Opinions vary on whether bug detection is a primary goal.

What the discussion says

  • Some see code review mainly as a way to prevent complex, hard-to-maintain code.
  • Others believe it's primarily for catching bugs and errors.
  • Several mention that code review also serves to protect senior engineers' oversight.
  • There is skepticism about the effectiveness of code review in bug detection.
“The primary purpose of code review is to maintain existing hierarchy.”
— cat_plus_plus
“Simpler code is nearly always better.”
— SketchySeaBeast

Join the discussion

Write your take first — we'll ask for email only when you're ready to publish.

  • Hacker News
  • Sure, ensuring maintainability is one of the benefits of code reviews, but I think it is a bold claim to say that's the solo purpose. For example, code reviews is also a tool that allows teams to get inform of the changes in the code and share responsibility of the whole code base.
  • True - the biggest thing I want to catch in an MR is "will this change lead us onto a path that is uglier, buggier, less maintenanable".

    People will generally copy and follow existing patterns, so for example if you let somebody add a new internal date time format, then soon your codebase will bifurcate and there'll be multiple inconsistent versions roaming around.

    The other stuff (minor bugs, overly verbose code) can easily be fixed. Paradigm rot cannot.

  • It’s probably important to define what sort of code review you are talking about when making broad claims about it.

    GitHub style asynchronous pull request review with inline comments is the norm now, but it’s not the only sort of review there is. I’m old enough to remember processes that include in person reviews that were more like a dissertation defense or conference presentation.

    The literature around this that shows that code review is a useful quality practice (in fact one of the only useful quality practices) comes mostly from much more structured review processes than we see now.

    My personal opinion is that before llms the GitHub style pr review was for making us feel better about our processes (or governance checkbox checking) and the age of llms will sweep them away as the cost/benefit is so much worse now.

  • > it is not in general possible to find bugs by examining the code.

    Oh hell yes it is, at every level of abstraction even. We call those things code smell... A file descriptor that hasn't been closed, a coroutine that hasn't been awaited, a big try/catch block that just falls back to some value without logging the error, wrong type castings, etc.

    As a general rule: Neither type checker, nor compiler, nor runtime should ever be steps that merely want to be satified - work with these steps and treat them as the valuable tools they are, and never work against them.

  • This just makes reviewers and authors lazier.

    The purpose of code review is multi-faceted. Hard to maintain? Yes. Might have bugs? Yes. Can be done simpler/cleaner? Yes. Is in line with project code style? Yes. Get someone else to also understand the code? Yes. Onboard junior team member? Yes. Sanity check design decisions? Yes.

    This flippant note is mostly more self-justification for being a lazy code reviewer.

  • My attitude has always been that code review is best thought of as the gate where code goes from being owned by the author to being owned by the team or project. The code I'm reviewing is not your code, it is code that is about to become our code.

    Maintainability is a major factor in that, of course.

  • What I find to be maybe the single most important part of code review is knowledge transfer.

    Our entire small team thumbs up a PR before it's merged unless there's a big rush on it, and this gives everyone on the team a rough idea of the state of the codebase at any given time. There's no being blindsided like "this whole system I depend on is gone" like I had happen at far more siloed places I've worked.

    Beyond that, it gives a forum to ask questions about how things work to further build understanding. On a high functioning team, every developer should have at least a modest understanding of the entire system, including parts they never touch.

    Another important feature is just the institutional knowledge check. For instance recently I made a small change to a table and a coworker pointed out that there was a microservice I wasn't considering that wrote to that table that would break (yes, sharing tables is bad design, unrelated). I had no idea this microservice existed let alone had access to this table. The institutional knowledge check here though prevented a larger issue and potential data cleanup situation.

  • Code review doesn't have a single purpose. Finding code that is hard to maintain is one of those, and and an important one, but certainly not the only one, and I'm not sure it is even the most important one. Other purposes include:

    - a safety check to ensure that if a developer (or AI) goes rogue, it is more difficult to merge malicious code

    - a second perspective from someone who isn't as close to the problem and might see a better way to do things, or problems that the original developer missed

    - in some cases having someone more familiar with other parts of the system look at it who can tell if it won't interact well with something else

    - ensuring there is at least one other person familiar with the code

    - a learning opportunity. The author can learn from feedback from the review, and the reviewer can learn from the code in the change. Especially important when the author and reviwer have differing seniority. When I mentor a new employee, I add them as a reviewer to all my PRs so they can see how I do things, and review all their PRs so I can provide guidance. And sometimes I even learn things from them!

    - yes, catching bugs, although this should not be the primary mechanism for that, and I agree is not the most important reason. It is especially important for security and performance bugs though, as those are harder to catch with automated testing.

Explore Birbla archives