Top
Best
New

Posted by ColinWright 9 hours ago

The primary purpose of code review is to find code that will be hard to maintain(mathstodon.xyz)
271 points | 149 commentspage 3
jdw64 6 hours ago|
It seems the form that code review takes depends on the structure of the organization. In practice, some places use code review as a way to assert hierarchy and tear someone down, while in others it's a friendly, knowledge-sharing exchange. Code review varies depending on the organization's shape and the manager.

And I agree to some extent with what the OP's tweeter said. these days, bugs can look perfectly fine on the surface, but when combined with the existing system, entirely new types of bugs emerge. This is an especially common pattern in the AI era: the added code itself isn't the problem, but it becomes a bug once it interacts with the existing codebase.

lazyasciiart 2 hours ago||
Unmaintainable is a bug. You just decided that you think code review is only meant to find one type of bug. Cool?
hakunin 5 hours ago||
I think the author is right.

There are many peripheral nice-to-haves you can get from a code review. Bugs, security, performance, correctness issues are all possible bonus findings you may get sometimes.

But there is only one _must_ in reviews: another person reading and understanding the code, possibly suggesting architectural improvements, or asking questions that should be answered by rephrasing the code for clarity, or by adding code comments. In other words: maintainability. That's the one thing that's not a bonus point, and is a constant for all code reviews.

ak217 3 hours ago||
The primary purpose of code review is whatever your organization decides it wants it to be. The post makes a good enough point but undermines it with this dogma.
whateverboat 6 hours ago||
I think when the the SICP authors said

> “Programs must be written for people to read, and only incidentally for machines to execute.”

people probably did not realise what it meant, but AI is bringing it to forefront. Huge amount of work we do is essentially to communicate decisions we want to take, are going to take or have taken. It is a cornerstone of our society when people are continuously exposed to the relevant decisions which are taken in order to build a shared understanding and move forward.

Programming was nothing but that. We did not have a good enough compiler till now and we definitely do not have a good enough language to describe what we need (mostly because thoughts and world in general are so much more complex than any language). And therefore, we used the same language for computer to execute our code and for us to read and understand it. But the reason we store our code in human readable language and not machine code is because we want to communicate the code to future self.

That's why Elon musks's statement about just directly getting a binary makes no sense, because the language used to specify that binary needs to be stored in some engineering records anyway, and then "that is the code".

Code review is also exactly the same, it is a signal which says, "I want to take this decision, are you okay with us taking this decision?" and everyone interested signs off.

Bugs finding are just people going, "I completely agree with the principle of the decision but this particular part of decision is anti-thetic to the principle, should we fix it?"

ruffrey 6 hours ago||
Agree and disagree. It seems hyperbolic to say code review isn't to find bugs; of course it is. That happens every week on my teams. But the main point is the knowledge transfer and readability of code.
barbazoo 7 hours ago||
> The primary purpose of code review is to find code that will be _hard to maintain_.

This makes me wonder if we all have a different primary purpose in mind when it comes to code reviews because that wouldn't be my number one. Talk within your teams would be my advice. Especially now with AI enabling more rapid changes.

d0liver 7 hours ago||
What if I told you that understanding what it is doing and finding bugs is actually the same problem?
akovaski 6 hours ago||
This is largely my take as well. When I review code, I am checking for correctness. If I find something is not correct, that's a bug (or a bug waiting to happen). If I can't understand whether or not something is correct, that's a problem. If I don't know what the correct behavior should be, that's a problem.

Though I do think there is value in the original post. Re-framing is a powerful creative tool when you hit a mental dead end. And the responses let people share the other benefits that change management can bring.

d-us-vb 7 hours 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.

So while there may be some overlap, particularly if each person has full understanding of the code's dependencies, in the general case, understanding code and finding bugs are quite different aims.

gste 5 hours ago||
"it is not in general possible to find bugs by examining the code"

That really depends on the quality of developers you are dealing with.

I certainly find myself assessing code quality, performance issues, shortcomings. Occasionally trivial bugs. Most importantly you review for taste, I'm tasting the code.

Maintainability is definitely important but is pretty subjective and is a subset of taste in general.

giancarlostoro 6 hours ago|
The other issue with code review, and I'm glad I've not worked with people like this anymore, for the person being reviewed: NOBODY IS ATTACKING YOU, nobody is saying your code is bad, the goal is to do a once-over for quality.

Another goal people often miss:

It's okay to ask "stupid questions" and I would argue as a Junior, ask away, even if no code changes happen, ASK. Kind of follows the spirit of the original post, which is, can you maintain this?

oh_my_goodness 6 hours ago||
>NOBODY IS ATTACKING YOU

Somehow this captures a lot of the culture for me.

giancarlostoro 5 hours ago||
Places I work at weed out for this. If people cant take peer review they sour the workday for others.

You were not hired to write perfect code, relax.

threethirtytwo 5 hours ago||
Not true. I’ve attacked people before in the sense I was disgusted with the short cuts they took and the things they tried to get away with in the code.

I’ve seen the malicious deletion of features in order to stay hidden and I’ve called it out.

giancarlostoro 3 hours ago||
That's not always an attack though, at least in a constructive critical review, maybe the approach could be different, but I'm also talking about when people are leaving comments that are genuine, professional, and tone is fine. In your case, yes you are attacking them I suppose, even though you don't really need to, you just need to rejec the PR and comment "hey, are you sure this is right?" and substantiate it. Sometimes people don't realize.
More comments...