75 points · by alexzeitler · 3y ago · 57 comments
- getting peer review on iffy code = 100%
- waiting for a PR to be approved for 6 hours, by 2 parties when it's typo fixes and adding some comments = ...
As a senior dev with over 20 years, I value code reviews from even junior devs. Heck it might spark a conversation that might mean everyone learn something, or get a refresher. It's also simply put: 2 brains are better than 1, particularly with codebase fatigue.
And by the way, in dynamic languages: even more so. Dynamic languages save you time in the writing side of things, which you pay back in the testing. Make no mistake, you are the compiler.
So my philosophy is if you feel this might benefit from another set of eyes, seek reviews. If you feel you're going to waste someone's time, don't.
But mission critical code, e.g. handling payment information, user privacy impact of any kind, business logic, should go through code reviews, on top of QA and UAT.
Trust people, don't trust code. And if you can't trust your people, you need new people(!)
I'd like to expand a little bit on this part:
> I value code reviews from even junior devs.
In fact it can be really valuable. If they don't understand it it means it is either too complicated or it might mean it is time to explain the necessary concepts to them.
When a review has found problems with my work, 90% of the time I've spotted them myself during that process.
This is arguably not a problem with the review process, but a problem of not being able to maintain an asynchronous workflow.
Git itself is made from the ground up to allow you to make a change, send it out, and then go focus on something else for the next few hours. It does require some amount of learning your tools (e.g., cherry-pick and rebase), and unfortunately most of the forges that people build on top of Git are quite bad at this. (Gerrit is the best one I know for this particular problem space; unfortunately, it has some other downsides.)
My tested and recommended process is working in pairs, rotating pairs regularly and sharing/rotating all tasks within pairs, equally. You have two people actively working together on each piece of code. They are supposed to both understand what is happening, care for quality and be vigilant to catch defects. This is also the right time to have actual input regarding quality or design improvements. And the code once it is done can immediately be committed and shipped so there is no awkward delay between code finished and deployment.
I also learned over the years pair programming is also a fantastic way to achieve some other goals like people socialising, getting to know each other professionally, learning from each other, newcomers getting bootstrapped, etc.
Pull requests degrade to nit picks that are irrelevant to code quality and code function to make the reviewer feel like they are contributing
Sorry to play devil's advocate, but pair programming is literally two people doing a job that has traditionally/historically been done by one person. There is no surprise this is going to cause raised eyebrows with management. Two devs sharing a keyboard is 100% going to be seen as two people fulfilling a single person's job to nearly anyone external to the role for obvious reasons.
People are definitely NOT taking twice as much time per-person to write a piece of code.
First of all, code review is already a cost tacked onto development to ensure quality. So one could say code reviews are a waste of time. Well... not necessarily. It is always cheaper to catch and fix an error closer to the source of the error. When the error happens in prod it may be costing your company millions, but the same error caught in review may mean a cost of somebody's 1h review and half a day to fix it and then re-review it.
So we are saying: it is better to spend a bit of extra effort upfront than let those quality problems spew uncontrolled into codebase and production environment.
Naively, pair programming means one person writes the code and another "watches" and catches errors. But that's not what is happening. People discuss the course of action so you usually already get better result with two people doing it. Then there is the fact that if one person would get stuck it is usually much faster to get unstuck with another person involved.
And you get other effects, too. For example, I find it impossible to procrastinate when working in pair with another person. It would be just disrespectful to the other person to be wasting time while we are both assigned and expected to produce results.
All this means that not only the quality is better than if one person worked on it, but also the work progresses much faster.
I would also suggest that in many businesses the most important factor is not development efficiency per se, but how fast can you deliver a given result. Meaning, if business figures out they want capability X, how fast you can provide it.
To get to X you create a project with tasks. Any project will have critical path and adding more resources to the project will not speed up the project at all. The only way to speed up the project is to either change the critical path to a shorter one or speed up the tasks on critical path.
There is normally very few ways to speed up development tasks. You can reassign them to your best/fastest devs. You can produce more technical debt. That's about it.
So working in pairs offers an invaluable ability to speed up the development process without creating more technical debt and without using your critical resources.
And yet another effect is scaling your development operations. Normally, adding more developers to the project creates more efficiency. Twice larger development team will not be twice more efficient. Working in pairs counteracts this problem a bit, ie. it lets the team be twice as large at the same level of efficiency/complexity. Any techniques that let you stave off the effects of growing organisation are very valuable.
I swear maybe 50% of review comments are either to make the reviewer feel like they aren't a rubber stamp or just to signal that they actually read the PR.
Code review is fine and necessary. The problem is when a coworker can veto your own work, rather than just review it and offer helpful suggestsions. Pull requests are simply an artifact of certain version control systems that have somehow become pervasive to our entire software methodology. It doesn't have to be that way.
It's not a question of trusting in perfection. Of course everyone makes mistakes. But do you trust your coworker to not be overly pedantic and opinionated, to not get in your way and block your progress? You shouldn't necessarily trust that either.
If they were, I would raise it with my line manager and try to get the issue fed back to them.
What kind of workplace do you not trust your coleagues to be reasonable?
I don't trust myself nor anyone to not make mistakes or have blind-spots that pull requests and code review helps catch.
Here's an example from today of an issue caught code review, that could have been a bug that easily slipped through testing only to become a hard debug issue months or years later:
"You're assuming the order here, but it should be set explicitly".
Caught by the reviewer, and easily fixed in seconds.
But that could have been a really expensive bug to fix later.
And it wasn't really through a lack of competence, just an oversight because the data wasn't necessarily sorted at that point.
And the gating helps enforce and audit that code is reviewed, that everyone can go back and read the reviews to understand the journey the code went through. If there's later a bug in that area, there are now two different people I can know to ask first about that code.
Making code review optional is a good way to get it waved through with little oversight.
Having the people who okay the request share responsibility for fixing that code is a good way to motivate better code reviews as well as share knowledge.
Why would a coworker want to block your progress? Maybe I've never worked anywhere toxic enough to understand.
This reads a bit weird so I'm interpreting it as "what kind of workplace causes you to not trust your colleagues to be reasonable?"
Lots. There are many places where developers will play outright power games in order to posture and preserve their position. The PR is a big spot where this can shine through in black/white. As a manager, I really have to police GitHub/GitLab/Bitbucket to ensure that this isn't happening.
I've had juniors, equals, and seniors hold up months worth of work for arbitrary reasons, purposefully pushing past deadlines. Some even admit to it behind closed doors/in meetings. Toxic work places surely exist.
---
To be clear, I am 100% in support of peer reviewed work as a SWE (PR's, external auditing, etc)... I'm just expressing that I've experienced the check/balances of peer reviewed work weaponized, typically to feign importance or as an unfair attempt to advance someone's career. I feel like it's just the human condition that some people will just take advantage.
Isn't that a strong signal that the culture is bad?
Maybe not of the entire company, but at least of the team that's happening in.
Me: "Code review is fine and necessary."
How did you turn "necessary" into "optional"?
This seems to be just more evidence that for some reason, some people can't seem to imagine code review without pull requests. Maybe you have to be older, and worked before git and GitHub existed? I don't know.
Let me spell it out more clearly: a pull request is when the reviewer can reject your commit and force you to meet the reviewer's demands. Whereas you can have mandatory code review without pull requests, where the mandate is just that someone has to examine your commit and comment on it.
> Why would a coworker want to block your progress? Maybe I've never worked anywhere toxic enough to understand.
Have you... heard of large corporations? ;-)
You seem to be against the concept of someone having the ability to veto your submission, and that is indeed what most people think of the purpose of code review is. If it doesn't pass muster, it doesn't get merged into the main branch.
- trust that your coworkers are competent code-wise - without this, you're gonna get frustrated that you're constantly having to clean up after them and catch problems they've created (whether in a PR gated process or later when you find the problem they already committed - note that this isn't solved by PR gating because someone else less competent might have approved the PR anyway)
- trust that your coworkers aren't going to be annoying with their reviews - you cover this one, you'll be constantly blocked if you can't trust that
When people complain about very large organizations and teams being too bureaucratic and annoying it's because their organization hasn't figured out a way of scaling that trust. There are coordination problems that become very hard: hiring quality bars for interviews; alignment on what to focus on in reviews; even just "my opinion on what code I can be trusted with" vs "the domain expert's opinion on how much I can be trusted with that code". So process is created because "trust" doesn't scale to huge networks of people. The author mentions TDD, that's just an automated form of process because honestly, you shouldn't even trust yourself with some things when it comes to code. ;) But in a huge org you can't even trust everyone else to be on the same page, and that causes friction if you want to go fast.
I trust that I'm not doing anything malicious, but I am also aware that I'm a human being and make mistakes. Sometimes really dumb ones. I like running it past another pair of eyes that aren't intimately familiar with my code to minimize the amount of dumb that makes it into the final product.
If someone leaves or has a bad meeting with a bus, at least one other person has some familiarity with that code.
PRs are good even if it's just within the small team as a way to peer review and have an extra pair of eyes.
It’s not to protect our default branches from our co-workers. It’s to protect them from ourselves. I work in a small team in a non-tech enterprise organisation, and each of our smaller code-bases tend to be mainly worked on by one person. Since the things are interconnected as stuff is today, I’ll sometimes add some react bits to our major front-end app that one of my coworkers have written 90% off, and sometimes he will add new controllers or features to one of the back-end services that I have build. In those cases, the strict default branch policies have never been an issue. Most of the time I’ll approve a Pull Request from my co-workers without reviewing anything, exactly because I trust them.
What I don’t trust is for myself to not cut-corners and not alter the default branch, or especially, to create a work-item on the DevOps board for what I think is a minor fix. I don’t trust myself to do that, because sometimes, I still turn the default branch rules off when I need to tinker because the red tape is annoying. Which is fine, until it isn’t, and the more times it isn’t the more I come to respect the red tape we’ve installed to protect us from ourselves.
I think the discussion around reviews becomes more informed once you're past that hurdle.
Also, as I've said before, architecture reviews yield 10x the value of reviewing programming logic.
It was more an organizational rather than peer level concern, but I've heard some good discussion of trust being the currency of the profession. Feeling like you are adequately regarded, even though it's likely few others really see into your part of the faxtory floor. Being able to trust the org to make good choices. The article focuses on peer relationships & risk & getting good output, but I think the social factors around trust more broadly are at least as important.
You can speed up the code review process by trusting people more on the basis of a longer tenure of high quality code and few bugs making it to production. Especially if they add screen shots or video snippets to the pull request to demonstrate the feature and to demonstrate edge cases.
Make it as asynchronous as possible and it scales to hardcore software engineering speed. And with time reduce the number of gatekeepers by assigning more authoritative titles with lower required numbers of approvals for things. That way we begin to promote the people who are demonstrating the most efficacy in shipping working code that gets the job done, rather than those people who are maxed out on talking a lot but don't ship any code at all. Or worse, the silent coasters who do nothing and say nothing lol. We see you now.
I don't understand the glee that software developers feel when they get to police their peers performance.
I honestly never see this in any other type of professionals. There's lots of other things that other professionals don't do that we promote, like micromanagement.
Given the joy you are expressing over being able to police others performance, I get why code reviews can sometimes be so despised: when you have people taking joy in pointing out others performance, like you appear to do, the code review is just another tool of passive aggressive bullies.
If you are writing a whole article on not trusting yourself, and never even mention the idea of engaging with someone dedicated to finding problems, then I can’t take you seriously.