I’ve trained more people on the subject of pull requests than I care to remember. But I’ve never came close to explaining the best practices as well as this Slack Engineering blog post does:
Basically, your reviewer is totally missing context, and it is your pull request’s job to give them that context. You have a few options:
- Give it a good title, so people know what they’re getting it into before they start.
- Use the description to tell your reviewer how you ended up with this solution. What did you try that didn’t work? Why is this the right solution?
- Be sure to link to any secondary material that can add more context — a link to the bug tracker or a Slack archive link can really help when describing the issue.
- Ask for specific feedback — if you are worried that the call to the `fooBarFrobber` could be avoided, let them know that so they can focus their effort.
- Finally, you should explain what’s going on for your reviewer. What did you fix? Did you have any trouble fixing the bug? What are some other ways you could’ve fixed this, and why did you decide to fix it this way?
Not every pull request needs every single one of those things, but the more information you give your reviewer, the better they will be able to review your code for you. Plus, if someone ever finds a problem in the future and tracks it down to this pull request, they might understand what you were trying to do when they make a follow-up fix.
Give your reviewer all the context they need to get up to speed with your bug so they can be an informed, useful code reviewer. It’s all about getting your reviewer onto the same page as yourself.