21 comments

  • donatj41 minutes ago
    What I find to be maybe the single most important part of code review is knowledge transfer.<p>Our entire small team thumbs up a PR before it&#x27;s merged unless there&#x27;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&#x27;s no being blindsided like &quot;this whole system I depend on is gone&quot; like I had happen at far more siloed places I&#x27;ve worked.<p>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.<p>Another <i>important</i> 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&#x27;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.
    • rowanseymour19 minutes ago
      We even find ourselves creating PRs in situations where the code is going to be merged immediately anyway, and tagging other devs, just so they have a convenient way to see what got merged and why. So people don&#x27;t lose track of what is in the codebase.
  • sjburt48 minutes ago
    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&#x27;m reviewing is not your code, it is code that is about to become our code.<p>Maintainability is a major factor in that, of course.
  • titzer42 minutes ago
    This just makes reviewers and authors lazier.<p>The purpose of code review is multi-faceted. Hard to maintain? Yes. Might have bugs? Yes. Can be done simpler&#x2F;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.<p>This flippant note is mostly more self-justification for being a lazy code reviewer.
  • BariumBlue49 minutes ago
    True - the biggest thing I want to catch in an MR is &quot;will this change lead us onto a part thatnl is uglier, buggier, less maintenanable&quot;.<p>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&#x27;ll be multiple inconsistent versions roaming around.<p>The other stuff (minor bugs, overly verbose code) can easily be fixed. Paradigm rot cannot.
  • pmelendez44 minutes ago
    Sure, ensuring maintainability is one of the benefits of code reviews, but I think it is a bold claim to say that&#x27;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.
  • mjd42 minutes ago
    The author is a mathematician, so when he says “it is not in general possible to find bugs by examining the code” he does not mean it is completely impossible to find bugs. He means only that it is not possible to find all bugs or even any particular bug.
    • d-us-vb8 minutes ago
      User names match... are you the original author? Why commenting in the third person?
  • brimtown19 minutes ago
    The best writing on this is the &quot;agent principal-agent&quot; problem, which correctly frames the problem of agents and code review in terms of trust.<p>This is why the solutions for high-trust environments (small teams) and low-trust environments (big companies, open source projects) will be different.<p><a href="https:&#x2F;&#x2F;crawshaw.io&#x2F;blog&#x2F;agent-principal-agent" rel="nofollow">https:&#x2F;&#x2F;crawshaw.io&#x2F;blog&#x2F;agent-principal-agent</a>
    • dirkc5 minutes ago
      Thanks, this articulates something that I&#x27;ve been struggling to put a finger on. You can&#x27;t review agent generated code the same way you would review a PR, someone needs to fine comb it to make sure everything is fine. And doing that for something like 100,000 lines of code over a few weeks just doesn&#x27;t sound realistic to me.
  • kasey_junk24 minutes ago
    It’s probably important to define what sort of code review you are talking about when making broad claims about it.<p>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.<p>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.<p>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&#x2F;benefit is so much worse now.
    • goalieca8 minutes ago
      On one of my first jobs, I had printed off change packages which had to be reviewed and signed. There was even a person owning the final copies in filing cabinets. This was more like traditional engineering and everyone had to think of software as more permanent.
  • jy1489811 minutes ago
    Not all bugs are buffer overflows, many are just the code not doing what it claimed at a high level
  • barbazoo38 minutes ago
    &gt; The primary purpose of code review is to find code that will be _hard to maintain_.<p>This makes me wonder if we all have a different primary purpose in mind when it comes to code reviews because that wouldn&#x27;t be my number one. Talk within your teams would be my advice. Especially now with AI enabling more rapid changes.
  • d0liver19 minutes ago
    What if I told you that understanding what it is doing and finding bugs is actually the same problem?
    • d-us-vb4 minutes ago
      Personally, I would tell you that whatever understanding you gain may still have bugs. Unless your understanding is as complete as a formal treatment of the code, then there may still be bugs in the code due to shared misunderstandings between author and reviewer. The biggest one is both having an incomplete understanding of what a library function does.<p>So while there may be some overlap, particularly if each person has full understanding of the code&#x27;s dependencies, in the general case, understanding code and finding bugs are quite different aims.
  • spacington51 minutes ago
    Found plenty of bugs by reading&#x2F;doing code review.
    • wayne-werwolf9 minutes ago
      As other&#x27;s already pointed out, the author argues about the primary intent of code review. Of course you find bugs while doing it, and that&#x27;s a nice side effect, but doing code reviews to assert correctness is maybe suboptimal QA. At least that is my take ...
  • Ozzie_osman43 minutes ago
    100% this. This is why it&#x27;s so hard to trust AI on code reviews, at least for now.
  • Pxtl13 minutes ago
    Well, the code review should also be reviewing the provided test code or test plan or whatever that will prove it does not have bugs.<p>You&#x27;re not reviewing the code to confirm that the code is bug free... you&#x27;re reviewing the additional code that confirms that the feature-code is bug free.<p>Any process that has a step of &quot;we&#x27;ll get to that later&quot; is a failure. That includes testing. Until there is some provided content that will be able to provide evidence that that code is safe to merge, it&#x27;s not done.<p>But yeah, I need to be able to understand what every line does.
    • jeffbee8 minutes ago
      Exactly. The procedure is to read the description of the change to understand its motivation, goals, and overall design. Then you read the tests, checking whether they are compatible with and cover all aspects of what was described. Then you can read the code under test but at that point you enjoy the assumption that it at least passed those tests.
  • phendrenad214 minutes ago
    Whatever purpose code review served pre-2002, post-2002 it serves as corporate audit coverage. A common (mis?) interpretation of SOX and SOC2 is essentially that the company must have a two-person sign-off on any system change that could damage the company or its reputation.
  • jerf42 minutes ago
    One of my favorite little things to notice is when everybody thinks they know what something is, and they all agree about it, but they in fact don&#x27;t agree. In this case we have the statement &quot;Code review is a good idea&quot;. What right-minded software engineer could possibly disagree with that?<p>But then notice 1. the number of people jumping up to say &quot;No, you don&#x27;t understand the point of code review&quot; and 2. how what follows &quot;The point is...&quot; varies between so many different people. I can&#x27;t quite say it&#x27;s a unique take per person, as I&#x27;ve seen before, there are some common threads, but they are also not all the same answer by any means either.<p>In this case, there isn&#x27;t a &quot;the&quot; point of code review to discuss. It turns out that while we all may have thought we were doing it for the same reasons, we aren&#x27;t. This is real. We don&#x27;t have the same goals, we don&#x27;t have the same methodology, and thus, the value we get from it may be different. And in fact it is perfectly reasonable to discuss the multiple cost&#x2F;benefits ratios that differ across the various definitions, because the simplification &quot;it&#x27;s good, end of story&quot; is destroying important distinctions.<p>In this situation, it is helpful to frame this as a matter of the costs and benefits of the various options available. Forget the statement &quot;code review is good&quot;; it is fallacious to start with that statement as an axiom and then argue about whether or not your definition of &quot;code review&quot; is or is not the &quot;correct&quot; definition so that your definition gets the &quot;good&quot; attribute applied to it. Consider the options directly.<p>(I have to admit I&#x27;ve used this effect in anger... in meetings where I can tell that everybody thinks they know what some project is but I can tell they all have a different definition of it in mind, but I also know it&#x27;s not going to happen anyhow, I don&#x27;t chase down the differences. Sometimes you can use this to your advantage to cut short what would otherwise be a quite interminable, yet ultimately pointless, meeting.)
  • othmanosx58 minutes ago
    I think you&#x27;re missing the point of code review. By the time when the PR is ready to merge, discussions around the architecture and how the code should be structured should already be part of the tech design of a given feature. So the discussion around whether a A feature is built and planned in a maintainable way, should be way before a PR is filed. A PR review is making sure that you verify against the already agreed-upon structure, making sure everything matches the plan, and also find bugs and stuff that was missed, according to the plan.
    • high_na_euv45 minutes ago
      Not every codebase project etc use such workflow<p>Also such approach doesnt work with bug fixes &#x2F; regressions
      • othmanosx33 minutes ago
        Every team should follow a plan, fine on a side project, but if you work in a large codebase with a bunch of devs, you need to have some sort of workflow to avoid stepping on each other&#x27;s toes.<p>bug fixes are supposed to be small, contained, if they&#x27;re rearchitecting the codebase, then they&#x27;re not _bugs_, but tech improvements, and need to be addressed differently and I agree that this should be flagged in the PR.<p>a PR review is the final defence line before a QA
  • high_na_euv46 minutes ago
    Uh.. why not both?
    • Pxtl11 minutes ago
      Because the reviewer is not magical. If there was something in the code the author couldn&#x27;t see, the reviewer probably won&#x27;t see it either.<p>The way to confirm that code does not have bugs is testing. So the reviewer is not looking at the code saying &quot;this will work&quot;, they&#x27;re looking at the code saying &quot;I understand how this works, it makes sense.&quot;<p>Evidence that the code is <i>safe</i> is something that <i>also</i> should be provided in the PR, but it is <i>not</i> the main code. It is ideally test automation that is just as understandable as the feature code, but failing that ad-hoc test evidence or a specific step-by-step plan with evidence of execution is good too.
  • cat_plus_plus51 minutes ago
    The primary purpose of code review is to maintain existing hierarchy by preventing junior SWEs from getting promoted by committing code that is smarter than what the senior architect can understand.
    • SketchySeaBeast48 minutes ago
      If the code is so smart that it&#x27;s not easily understandable, it&#x27;s not easily fixable. My transition from junior to senior was accompanied by the realization that simpler is nearly always better.
      • sjducb13 minutes ago
        Good programmers write code that’s so simple and obvious it looks like anyone could have written it.<p>Bad programmers make the simplest things really complicated.
      • cat_plus_plus33 minutes ago
        Write me simple AI inference code that has high performance in big batches.
        • SketchySeaBeast17 minutes ago
          I don&#x27;t know enough to speak about that particular domain, but if the junior is writing something the senior can&#x27;t understand, that&#x27;s always going to be a problem. That code becomes the team&#x27;s responsibility, and that code needs to be able to be maintained by the entire team, not only by the junior with something to prove.<p>Who is getting called at 2 AM when something breaks? Not the junior.
        • AlotOfReading13 minutes ago
          Does tinygrad not count for some reason?
  • grayhatter42 minutes ago
    &gt; many people misunderstand the purpose of code review<p>Oooh, I bet including the author? Yeah, right there, he fails to make any qualifications for his statement, making it factually incorrect.<p>There are plenty of reasons to do code review. If you force me to, I&#x27;ll define it as information transfer. The point is to have a conversation about the code. To expand both people&#x27;s understanding about the codebase. Everything on top of that is extra. I&#x27;ve found real and significant bugs doing code review. In large part because I understand the codebase better than the author. That&#x27;s finding and preventing bugs.<p>I also read PRs looking for malicious code trying to sneak in, you never know, the person I&#x27;ve called my best friend, someone with opsec better than mine, may suddenly have turned evil and this is the PR where they&#x27;re finally sneaking in the back door.... that&#x27;s never happened yet, but fingers crossed!<p>&gt; As everyone should know by now, it is not in general possible to find bugs by examining the code.<p>... I&#x27;d love to know what the author really meant to write here, because it certainly wasn&#x27;t this.
    • smcameron2 minutes ago
      He&#x27;s a mathematician, so what he means by &quot;in general&quot;, is &quot;in every possible case&quot;, so what he means is, &quot;not all bugs may be found by code review.&quot;