3 ms·
Doing a good code review is hard. You cannot do it in one pass, but of course projects are always late so there is pressure to approve. If you want code revie
by bluGill 2y ago
Doing a good code review is hard. You cannot do it in one pass, but of course projects are always late so there is pressure to approve. If you want code reviews to be good you need a policy that the reviewers need to approve it 3 days in a row without changes, but of course management wants to ship it and get on with the next feature.
It is easy to find nits. Most people will notice a spelling error out of the corner of their eye and zoom in on it. (I'm a terrible speller and I do this all the time). It is much harder to notice that the code is wrong and has bugs. I've passed many code reviews with a few nits to fix and push, only the next day did I realize there were serious problems with the code.
- gnulinux 2y ago> projects are always late This is the root of all evil. The artificially created deadlines that make something that can be resolved next week "urgently today" just to increase your adrenaline levels so you work 30 mins more today is what causes a lot of software to end up being a piece of shit. Software is about deep thinking, and comprehensive understanding. Yes, it's all about trade offs, but there is a point where things can't be any faster.
- mikepurvis 2y agoI agree on one level, but I also know that I'm a person who needs to have some kind of external incentive or else I'll just mire myself in endless rewriting and refactoring; unclear whether that has to be a boss/customer wielding a deadline or if it's enough to have a colleague who leans slightly more to the other end of the practical-idealistic continuum, but I know my best work happens with at least some kind of pressure being applied.
- ngcazz 2y agoI was recently diagnosed with ADD, and learning that about myself explained a behavior of mine which seems diametrically opposed to yours - the pressure of a deadline makes me panic, and somehow my outlet is bikeshedding. Give me daily and weekly commitments, and I'll do my most focused and highest quality work.
- bluGill 2y agoI think you are missing something: wanted features always exceeds time. You need some form of deadline to force your to think about what features to cut. Nobody wants to cut any feature that could make it in until forced to and so you are always late. The deadlines are artificial, but once they exist they force a lot of real scheduling on many others and so they become real. In theory you can change them, but in practice people are depending on you. Nothing is wrong with what you said, but keep it in context of the above.
- gnulinux 2y agoGP here, I don't disagree with you, engineering is all about trade-offs and you can't engineer things to perfection by taking months to solve easy problems. You need progress, and efficiency so sometimes less important problems need to be fixed with less than ideal hacks etc. I agree with this, but having a culture of "everything is due yesterday", "if it can be done in 6 months, tell customer it'll be ready in 2 months" etc just to create stress and increase productivity lowers the engineering quality exponentially more than it increases productivity and expediency.
- kolme 2y agoYes, this is precisely why I don't like sprints. Scrumban is less stressful.
- jader201 2y ago> You cannot do it in one pass > If you want code reviews to be good you need a policy that the reviewers need to approve it 3 days in a row without changes I may be misunderstanding, but it sounds like you’re dealing with very complex PRs/commits. I think the first problem to solve is get your commits to a reasonable size, so that you don’t need 3 days worth of approvals and multiple passes for review. (That sounds insane to me!) My typical commits are maybe 100-200 lines (many of them much smaller), so needing 3 days of approvals would be way overkill. And a single pass is plenty.
- zelphirkalt 2y agoWait, your commits are hundreds of lines, or your MRs/PRs? I like to keep commits as atomic as I can, not always succeeding, but often cutting commits to leave the repo in working state after a commit. Very rarely commits become 100 lines of changes. Perhaps those are variable renamings of things that are used in many many places? Or perhaps some wip commit, just making sure work is commited at the end of the working hours? A single pass often cannot work, if there is a single improvement to be made, since that implementation of the improvement needs to be reviewed again, unless it is already literally a suggestion of code by the reviewer.
- sigseg1v 2y agoFor me, changes are as small as possible, however it depends what I'm working on. Currently I'm doing major refactors to get a 1.5 MLOC monolith codebase onto a new runtime. This involves significant refactoring. You don't want to change many things at once, so one refactoring for example might be to make a commit which removes a pattern that will no longer exist in the new runtime. That can easily be 2000 files changed for a total of 10,000 lines. The commit is atomic and does one thing and would not make sense to split up. With that said, even though it's the same atomic change in each file, the reviewer would still need to check them all.
- jerf 2y agoIf ever there is a time to avoid bikeshedding consciously, it is during code review. Easy nits are of proportionally relatively small value. It's not misspelled comments or "not quite the variable name I would have picked" that brings down systems in general. One thing I depend on in my reviews is that the programmer has indeed verified that it does what it says it does, preferably via some unit testing. That frees me to consider architecture things and whether there's a lurking bug without having to review whether it works. This has been particularly helpful in our Infrastructure-as-Code reviews. Many such reviews are post-facto; they've already been run, we know it brings up the right infrastructure already, and the review is to make sure it's architecturally heading in the right direction and maybe that tagging standards weren't accidentally violated and other high level, important things, not whether we like the particular name of a subsystem. Getting this balance is probably the hardest thing about code reviews. Also, one of the main things in code review is having extra eyes validate that nobody's putting obvious back doors in the code. If you've done that, you've brought some value even if you do nothing else. If a bug gets past the person authoring the code, it's not a huge shock that it'll get by someone who is not in that headspace, doing something else, and has a completely different context loaded. The idea that it wouldn't borders on magical thinking. But at least you don't see any "eval(base64_decode('big long string'))" today. The goal of reviewing is just to up your team's game a bit, not guarantee on their own that no bugs will make it to QA or prod or customers. They're part of the portfolio and shouldn't be treated as anything more.
- awkward 2y agoWhat kind of load is code review bearing in your process that you want 3 days of active work to approve? Some mixture of automated validations, acceptance testing, and manual regression testing should cover whether the code is correct beyond review. That seems like a level of rigor that only systems with very significant failure cases could sustain and still be built.
- bluGill 2y agoFailure is expensive if customers go elsewhere. I'm not in the web world where we can push to production multiple times per day. I work with embedded systems which are not even in range of a cell phone signal in some cases (we are looking at starlink), so updates mean a human needs to physically go out and update the device, and in turn updates are expensive.
- corytheboyd 2y ago> I'm a terrible speller and I do this all the time Why are you not using a spell-checker in your IDE? I don’t get why people don’t do this, it’s so easy, and it makes you look a lot more professional when you aren’t submitting constant spelling and grammar errors. FWIW I would never bring it up in code review though, waste of time.
- nox101 2y agoAgree on the spell-checker. I also makes me choose names that don't trigger the checker. I'm using https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker https://marketplace.visualstudio.com/items?itemName=streetsi... WhichSpellChecksCamelCase and_snake_case On the other hand, on my team we just say > nit: spelling but approve the change.
- bluGill 2y agoEvery spell checker I've seen is more trouble than it is worth. They can never figure out what word I mean.... I bring up spelling in code review, but they are always a "fix and push without farther review"
- packetlost 2y agoMy policy on code reviews is: my brain is a bad interpreter. Either I run the code and see that it works, I trust the tests (see #1 why this doesn't work), or I rubber stamp it and move on. Which I do mostly boils down to what the risk/impact of a bug in that part of code would be, and I've been around long enough to have developed the intuition to usually be right.