Live data from Hacker News

The primary purpose of code review is to find code that will be hard to maintain

mathstodon.xyz

151–160 of 193 posts

Re: The primary purpose of code review is to find code that will be hard to maintain

#151

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 sh…

> 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.

Synchronous review is still possible today! One of my earliest managers taught me that if a "standard" code review goes back and forth more than once, it's almost always better to just hash it out in person (or on a Zoom call, when at least one person is remote) and then go back and post a comment summarizing what consensus was reached. To use a contorted technical analogy, asynchronous text communication can be lossier in terms of what information it's able to successfully encode than verbal, and the throughput is lower, so sometimes it's worth it to pay the synchronization overhead when you need to exchange a lot of information.

Re: The primary purpose of code review is to find code that will be hard to maintain

#152

> As everyone should know by now, it is not in general possible to find bugs by examining the code. Lost me here. I would agree that it’s not possible to find every bug by examining code, but in real code reviews bugs and errors are identified by reviewers all the time. Reviewers lend their past experience to the situation, identify some unnoticed interaction, think of an edge case that the author hadn’t considered,…

> in real code reviews bugs and errors are identified by reviewers all the time.

I think that this would be better directed at the person who posted "no one ever finds bugs during code review" rather than at the person who said that just re-reading code is (obviously) not an effective way of debugging, and is better thought of as a time to make code clear enough that bugs will be more apparent or less likely to be introduced by later authors.

> I’m not a fan of these blanket declarations that code review isn’t about reviewing code.

Using a shovel to dig a hole isn't about using a shovel, it's about digging a hole. Reviewing code is a necessary prerequisite to finding code that will be hard to maintain (and finding any number of other things, and knowledge transfer, and getting acquainted with coworkers' coding styles and domains, etc.) It is not a purpose in itself, but a tool.

> code review isn’t about one thing.

But you just said that code review is about reviewing code, and explicitly not about "some other thing" in the beginning of the sentence, right before listing two other things that code review could be about, and then insisting that it could be about many other things. The author is saying that it is primarily about one thing, likely because in their opinion it is most effective at that one thing, and that one thing goes a long way into solving other issues.

It isn't like they said "ignore bugs during code review, never learn anything from it."

I agree with the OP. Code reviews are finishing steps where things are polished, and polished code should be correct code, but more importantly intelligible code. If your code is clear, the mistakes will be obvious to more people than if your code is not readable. To make it simple: you've written something and it feels done, now you want someone to read it to see if it makes sense to them. No different than any other type of writing.

Re: The primary purpose of code review is to find code that will be hard to maintain

#153
post #13

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.

Apparently the mathematician author doesn't understand the meaning of his own natural language quantifiers. “it is not in general possible to find bugs by examining the code” means “it is not in general possible to find ANY bugs by examining the code”, not “it is not in general possible to find ALL bugs by examining the code”.

And the first interpretation is relevant but wrong, whereas the second interpretation is true but irrelevant.

P.S. It seems that the author meant to say “it is not in general possible to find a given bug by examining the code”, i.e., "not (for all bugs B it is possible to find B)", which again is true but not relevant.

Re: The primary purpose of code review is to find code that will be hard to maintain

#154
post #52

The author seens to misunderstand the purpose of code review. The purpose is, literally, review the code. Review means basically to think/talk about something again in order to make or not changes on it. When you review something (including code), you are basically asking for yourself: "Should it be changed or it's okay to stay like this?" In order words, the purpose of code review is to or not ask for changes on the…

> Review means basically to think/talk about something again The rest is not part of the definition; critics don't review movies in order to change them. But just accepting that at face value, making code more readable is a "change." I don't know what you're trying to say here.

To criticize is, basically, to say what should have been different. It is in the past, yet it is still about what should be changed.

> making code more readable is a "change." I don't know what you're trying to say here.

Yes and this is exactly what I am trying to say. The author limited what is the purpose of a code review like it's has really this limitation but, in practice, the code review is widely about what you think it should changed on the code by multiple reasons: readability, manutenibility, performance, security, bugs, use cases, test coverage etc.

Making code more readable is just one of the reasons why you want the code to be changed on a pull request, it's not the primary purpose.

Re: The primary purpose of code review is to find code that will be hard to maintain

#156

I don't know about many people, but the author for sure doesn't understand the primary purpose of code review. If the primary purpose of code review is to assess maintainability, there is no need for review, that can be done by automated tooling (formatting, bad naming, cyclomatic complexity etc.)

> the author for sure doesn't understand the primary purpose of code review.

What's the worth of this comment if you've decided to keep this purpose a secret?

The second sentence is just nonsense. There are no automated maintainability devices (quite yet.) You seem to be literally declaring that linting is the only worry that any software project would have when it comes to maintainability. Everybody is linting, the conversation begins after that.

Re: The primary purpose of code review is to find code that will be hard to maintain

#159
post #153
post #13

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.

Apparently the mathematician author doesn't understand the meaning of his own natural language quantifiers. “it is not in general possible to find bugs by examining the code” means “it is not in general possible to find ANY bugs by examining the code”, not “it is not in general possible to find ALL bugs by examining the code”. And the first interpretation is relevant but wrong, whereas the second interpretation is tr…

Thank you, I thought I was getting crazy! The self-proclaimed amateur mathematician[0] who quotes his own writing in 3rd person has some stuff to work on I guess.

[0]: https://blog.plover.com/meta/about-me.html

Re: The primary purpose of code review is to find code that will be hard to maintain

#160

Found plenty of bugs by reading/doing code review.

As other's already pointed out, the author argues about the primary intent of code review. Of course you find bugs while doing it, and that's a nice side effect, but doing code reviews to assert correctness is maybe suboptimal QA. At least that is my take ...

The author made multiple statements, and one of them was “it is not in general possible to find bugs by examining the code”, which is simply false.
Post reply on HN