News for hackers. Stuff that matters.
Re:Code review review is the manager’s job by ahartmetz on Wednesday August 15, 2018 @06:42AM (#17765038)
Yeah, I see more projects with bad code review culture than good. There are many things that managers can do about it.

* Assign enough time for code reviews - otherwise developers will just care about their own code submissions and let reviews rot.

* Establish productive code review rules. E.g. always go from big picture to details, otherwise you'll waste time on details that you end up throwing away.

* Make reviewers co-responsible for the quality of code reviewed, otherwise instant acceptance for everything becomes attractive.

Re:Code review review is the manager’s job by quantumhobbit on Wednesday August 15, 2018 @07:41AM (#17765276)
I just left a job with a truly toxic code review culture.

- managers would swoop in and leave incorrect criticisms. Asserting plainly false things and in one case reviewing python code as though it was JavaScript.

- devs would make conflicting requirements for improvement. Dev A demands change A. Dev B wants change B. A and B are incompatible and neither dev will back down. Management of course refused to help settle the argument.

- change requests completely unrelated to the PR being reviewed would get crammed into the PR. So every small code change could balloon into weeks on refactoring work.

- Often times code review comments were made without ever reading the code being reviewed. Such as a comment of “Why aren’t you using library X?” sandwiched in between invocations of library X.

The culture was clearly rewarding people for shitting on others work instead of doing any work themselves. Getting even the simplest code changes past required endless meetings explaining the most basic facts about computers.

So glad to be gone from there.

Re:Code review review is the manager’s job by BeetleB on Wednesday August 15, 2018 @11:06AM (#17766559)
>devs would make conflicting requirements for improvement. Dev A demands change A. Dev B wants change B. A and B are incompatible and neither dev will back down. Management of course refused to help settle the argument.

This was a problem in my previous job. Options I thought of:

1. Get a moderator. This is what we did. He did not just settle disputes - he did more than that. But it's good to have at least this role.

2. Have a total of 4 reviewers review the disputed section. If there is a majority, change it. If it's a 2-2 split, just leave it as is. (Team did not accept this).

3. Disputed code (whether changed or not) should have comments saying this vs the alternative was discussed in a code review. Why? Because if there isn't consensus, over time, people are going to keep changing those lines of code back and forth (some developer who was not involved in the review will decide to refactor - rinse and repeat).

Re:Code review review is the manager’s job by ahartmetz on Wednesday August 15, 2018 @09:42AM (#17765934)
Some of these are really something else. Of some I have seen minor cases. "While you are changing this code, why don't you also..." is sometimes okay. Conflicting requests from reviewers, I have seen those happen due to neglect from the reviewer most in charge of the code. If they cared, they'd have used their technical competence, or rank if necessary, to set the direction.
Re:Code review review is the manager’s job by bluesnowmonkey on Wednesday August 15, 2018 @11:19AM (#17766687)
Not sure if management is right for #2. There should be some kind of tech lead in place to resolve technical conflicts. Design by concensus doesn't work well.
Re:Code review review is the manager’s job by camgunz on Thursday August 16, 2018 @12:46PM (#17776301)
Some of this stuff is bananas, and you're totally within your rights to say, "please read this PR; I am using this library / this is Python.". But if someone's asking me for a refactor, I say "let's make a separate ticket for that", and if multiple people ask me for conflicting things, it's totally fine to say "please figure this out and update this PR, or I'm ignoring both of you". I think you made a good call switching jobs, but sometimes a great job is worth dealing with some troublesome processes.
Re:Code review review is the manager’s job by JoeAltmaier on Wednesday August 15, 2018 @10:07AM (#17766099)
This has become the norm in the assembly-line culture of agile development? Last two gigs I heard about, this was baked into their process. Projects were delayed weeks or months; projects missed deadlines.
Re:Code review review is the manager’s job by ljm on Wednesday August 15, 2018 @01:44PM (#17768051)
I've mostly battled with 1 and 3, like they're two extremes on the spectrum.

In the first instance, I suspect there is blame culture or otherwise the developers previously had that experience and thus carried the baggage to the new job. I believe this is how you can get pull requests that either never get approved or merged (nobody wants their name attached to it in case they get called out). When it comes to not having time to review at all, I suspect that's the classic "I'm too busy" excuse, where if the whole team is too busy working independently then they can't ever expect to get anything to production without a serious effort each time.

In that instance the code review and lack of productivity is just a symptom of a lack of team dynamic.

The latter point is weird because I've had that and I didn't enjoy it at all. I could never tell if the approval was because the work was good or because it was a rubber stamp operation. Especially based on other feedback it felt like I was being put on a pedestal and I hated that I could basically do no wrong, even when I did because we merged and then I had a gut feeling that I fucked something up.

I'm not sure accountability would fix that particular manifestation of the problem.

Re:Code review review is the manager’s job by KKKKkkkk1 on Wednesday August 15, 2018 @10:41AM (#17766332)
> Establish productive code review rules. E.g. always go from big picture to details, otherwise you'll waste time on details that you end up throwing away.

Well, that's a nice rule. Another one I heard people say is that code reviews are not for arguing about architecture or design decisions. If we take those two rules together, code reviews are good neither for discussing the details nor for discussing the high-level picture. Which in my experience is about right.

Re:Code review review is the manager’s job by quantumhobbit on Wednesday August 15, 2018 @11:16AM (#17766652)
Right. Code Review should be about catching mistakes. The high level design is already known, and the low level details are checked by a linter. Code Review just makes sure that you didn't accidentally introduce a bug and that the code has appropriate tests.
Re:Code review review is the manager’s job by FlipperBucket on Wednesday August 15, 2018 @12:14PM (#17767181)
> Code Review should be about catching mistakes.

Overly-complicated code is a mistake. Maintainability matters almost as much as a passing unit test. You want your code reviews to catch meaningful things, but they often end up being about things like this (fixing inefficient small bits of code).

e.g.

     function isDry(weather) {
         if (typesUtil.isSunny(weather) ||
             (!typesUtil.isSunny(weather) && typeof weather.hasSnow === 'boolean' && !weather.hasSnow)) {
            return true;
        }
        return false;
    }
vs

    function isDry(weather) {
        return typesUtil.isSunny(weather) || 
        (typeof weather.hasSnow == ‘boolean’ && !weather.hasSnow);
    }
vs

    function isDry(weather)
        var hasSnow = false;
        if(typeof weather.hasSnow === 'boolean') {
            hasSnow = weather.hasSnow;
        }
        return (typesUtil.isSunny(weather) || !hasSnow);
    }
Re:Code review review is the manager’s job by ahartmetz on Wednesday August 15, 2018 @12:25PM (#17767265)
When you are dealing with an open source project, people will just show up with small and sometimes large changes. In that case, you may need to review design.

There is also "minor" stuff a linter won't catch, such as bad naming. IMO naming is actually quite important.

Re:Code review review is the manager’s job by johnb on Wednesday August 15, 2018 @06:45AM (#17765046)
Those are all really good points.

I have a recollection of seeing a study once that found the best balance point of review time vs dev time but haven't found it again. I recall it being somewhere around 20-30% but now that I can't find it I'm questioning my recall.

Re:Code review review is the manager’s job by johnb on Wednesday August 15, 2018 @07:38AM (#17765264)
I definitely overstated here sorry. Found the excerpt I was remembering in my copy of code complete "On a project that uses inspections for design and code, the inspections will take up about 10-15 percent of project budget and will typically reduce overall project cost".

So assuming the same payoff benefit (big if, but let's go with it) between PR style reviewing and more formal inspections, every engineer should be spending around four or five hours a week performing reviews to hit the sweet spot.

Re:Code review review is the manager’s job by hodgesrm on Wednesday August 15, 2018 @10:02AM (#17766065)
The company where I work has senior engineering staff whose main responsibility is to provide technical guidance. This includes doing code reviews and creating a good review culture by example. We're judged by the overall project outcome in the same way that the managers are.

Even with that structure I found it challenging to develop a good reviewing style that picked up the important stuff without getting bogged down in silly details that lead to arguments. Reading John Ousterhout's "A Philosophy of Software Design" was really helpful. He focuses on module decomposition, quality of public interfaces, and documentation among other things.

Re:Code review review is the manager’s job by JoeAltmaier on Wednesday August 15, 2018 @10:05AM (#17766086)
So often an ivory-tower group with gate-keeping authority into the code base can derail a project and frustrate developers to the point they quit. Comments about module decomposition seem pointless to someone under the gun to deliver by a demo date. The poor developer is reviewed badly and their career suffers, because they were essentially powerless to deliver on time because their null-pointer-checking didn't appeal to some obstructionist reviewer.

So I won't submit to a committee review before my code is accepted. Its a recipe for anguish and failure.

Re:Code review review is the manager’s job by hodgesrm on Thursday August 16, 2018 @11:57AM (#17775757)
What I'm describing is not a committee review any more than having Linus Torvalds review Linux kernel changes or Ben Pfaff review Open vSwitch changes. I can write code just fine myself, but it's more effective to focus on making others productive because the whole project gets more work done that way.

Module decomposition is usually something I try to pick off in design, but when accepting pull requests from outside it's a critical consideration. We're not blocking creativity but trying to ensure that the code base not only remains high quality and that the design morphs appropriately over time as we meet new requirements. By making this a review point you can help create a culture where engineers think about it before submitting. That in turn makes it easier to justify dates to managers.