Yes, I know. A little bit of controversy in the title of this post could have triggered your attention. But hear me out.
I think that the pull request model is a good fit for open source development where people are working in their spare time on projects and want to design, collaborate and review in the open before accepting changes. I don't want to go in too much detail, so if you want to learn more about this model, check out the documentation on Github or the Atlassian BitBucket website.
Let me focus on the reason when and why I don’t like to use pull requests. I don’t think they are a good fit for dedicated software development teams working in close collaboration fulltime on the same codebase. In these teams I see pull requests used as a quality control mechanism allowing another (senior) developer to review the changes before approving them and pushing them to the master branch.
Pull requests are not a good fit for dedicated software development teams working in close collaboration fulltime on the same codebase.
After observing multiple teams using this approach, I noticed the following patterns:
- It slows the team down. As work is waiting to be reviewed, context switching is necessary when feedback finally arrives. Especially when a more senior person needs to review the code, this person becomes the bottleneck slowing down the whole team. It wasn’t exceptional to see pull request remaining unreviewed for multiple days. This makes merge conflicts much more likely.
- It leads us further and further away from continuous integration. To avoid the bottleneck, developers tend to work longer and longer on their feature branches postponing creating pull requests until their feature is completely ‘done’. As a consequence pull requests become larger and larger. I’ve seen pull requests that impacted 50+ files.
- The quality of the codebase decreases over time. This is quite contrary to what you would expect but unfortunately this is what I observed monitoring the work of multiple teams. Let me explain why this happens; it is all related to the previous observation. When pull requests get larger, it becomes a lot harder to review them. No one likes to read through hundreds of lines of code or is able to fully understand and grab the impact of a change spanning tens of files and classes. As a result the reviewers become more sloppy and will approve a pull request sooner (especially when the pull request is open for a few days, a long list of other PR’s are waiting to be reviewed, the business wants this feature yesterday and the person doing the review is the bottleneck from my first observation.)
Instead of using pull requests I would suggest to use trunk-based development together with pairing or mobbing to eliminate the need for code review. If you want to keep code reviews, you can conduct code reviews after integrating, rather than as a pre-integration gate. Let the team work in a continuous integration fashion integrating many times per day directly on the trunk (or master).
I noticed that using this approach has a positive impact not only on speed but also on code quality as we want to have the master branch in a releasable state.