by austinl · 4y ago · 0 comments
Diffs that are > 500 lines either tend to sit in code review for several days or get the lazy accept and break something. If I absolutely cannot stack for some reason, I'll put up the PR, then set up time with some teammates to review it together. That way it gets merged that day and I avoid massive rebase conflicts (or I take their feedback and go back to the drawing board).
More info about PR stacking — I wish there was an easier git/GitHub interface for doing this:
- https://0xc0d1.com/blog/git-stack/
- https://kurtisnusbaum.medium.com/stacked-diffs-keeping-phabr...
It’s good to do small iterative changes, but it’s not a silver bullet for review challenges.
Re an easier tool, I'm one of the co-founders of Graphite (https://graphite.dev), we built this tool literally to help you stack PRs on GitHub (former FB'ers who missed a stack-based workflow). It does not require your team to change their workflow. If you're interested in giving it a spin, happy to let anyone here through the waitlist, feel free to just dm me on twitter (@tomasreimers) or email me at tomas@graphite.dev
If you're new to the concept of stacking, you can read our post on it here: https://graphite.dev/blog/post/DThX8ffP1gmxWJChEv0y
And a tutorial on how to do it here: https://graphite.dev/blog/post/N8SOs49y4bYdV1Vjf5qE
As the author of git stack, with all relevant biases, I recommend
- git stack for automating what you are already doing
- git branchless for more power at the risk of incombatibilities because its only as good as the data fed to git hooks
- jj if your open to something very different
The problem is, they're a pain to work with in GitHub and so only a very small number of people end up learning how to work with them.
Sadly, the culture in some places mandates one pull/merge request per Jira issue/feature and therefore this isn't viable.
And even when it's not a top down decision, your colleagues might just say that actually they want to see all of the changes together once they're done because that's what they are used to, which will lead to you getting feedback pretty late in development and will probably make you need to refactor large parts of your code.
With that in mind, you can change the top of the stack PR to the default branch to get a complete diff.
I haven't always been working with "best and brightest" although that's not a dig, as the people I'm working with now are probably in the top 0.001% of Git users, nobody who does not work on Git as a discipline in and of itself can live up to this standard.
Well, i wouldn't say never, but you are spot on about the rest!
Many don't want to deal with the additional cognitive load. Of course, not everyone uses GitHub either: as far as i know, GitLab doesn't really have good UI for stacking merge requests (their terminology for the equivalent of GitHub's pull requests) and as a consequence you end up having to write comments about the order in which things should be reviewed.
Now, admittedly, i've personally done it in cases where it makes sense (e.g. separate bunches of refactoring or preparatory work from the introduction of new features), but it was definitely the exception, not the normal way of doing things.
I feel like if i started stacking my changes, some of the more established developers would furrow their brows and complain in the stand-up about needing to spend extra time on review, as they have in the past. Essentially, it's not enough for an idea to be good (or at least a good fit, given its drawbacks), but you also need to read the room!
I think the comment you responded to is talking about deconstructing a single chunk of work into multiple commits and opening a PR for each one, rather than combining several units of work into one PR.
The first might be pretty happy to see a bundle of smaller patches, and the second would be very upset because his workflow is now X times larger if they want to request changes.
I sometimes found myself going, "I could split this PR up into smaller ones but I'll skip it just this once" and it's been a mistake every single time.
Few things are a mistake so reliably as that.
These days, I always split it up until multiple PRs.
It would be nice to open just one PR with several sets of changes where you could provide context for each set of changes.
With GitHub you could do this by having a commit per each set of changes, but you can't add a description for each commit.
You end up having a PR that points to the previous PR, and then you have to decide if you run CI in that PR or just the last PR, and then having some merge issues. With all this hassle people usually just open a big PR with all the changes or decide against doing that small refactor (because it would have to do it in another PR and the hassle is not worth it), overall this ends up decreasing code quality in the codebase.
- 200 lines of statically typed, pure functional code with high test coverage
- 20 lines of code with I/O, parallelism, mutable state and/or interacting with external APIs
I find it way less cognitively draining to review a big chunk of blue ocean code with good patterns, than even small amounts of code which requires me to maintain any kind of state in my head, or try to think about the consequences of how this change interacts with the broader system. I'd say that some kinds of code are easily 10x more cognitively draining than others.
If you write the regex like you would production code, i.e. with whitespace, newlines, and comments[1], I imagine 200 lines of regex would be about the same as 200 lines of any other type of production code, be it APL, Haskell, or conjunctive normal form.
I realise this is a bit of a circular argument: if you write the code such that 200 lines is about n units of review in a specific language, then 200 lines will be about n units of review in any language. But that's also kind of the point. There's a very specific logic density that you can accomplish for production code to be readable, and that results in about that density being reviewed.
[1]: In Python you can do this with the re.VERBOSE flag, in other languages you can do it by breaking the regex apart into separate variables that are then combined together.