In many years of writing and reviewing code, I learned a few secrets to craft better pull requests and review code more efficiently.
I poured all these secrets into my new book Pull Requests and Code Review, but you’ll find here a preview with these 13 tips, that you can already use in your developer activity.
Can you think of more tips? Share them in comments 😉
A PR draft helps you organize your ideas and document your progress, while you’re still working on your feature.
The best way to get a quick and efficient review is to keep your PR small and well documented (with all the necessary context). You’ll also increase you chances for future PRs by delivering great code now!
Find all these tips with and more, with more real-life examples and actionable insights in my free book Pull Requests and Code Review: Best Practices for Developers, from Junior to Team Lead.
Put yourself in the shoes of your reviewer, anticipate questions and use comment your own code when you think it can help them.
Don’t assign your PR to the entire world. Choose your reviewers carefully to get a relevant review, without waiting too long for approval.
Be open to feedback, ask for clarification, say when you disagree (with respect), and always respond to comments.
Everybody has many PRs to review and little free time to. If you review other PRs, you increase the chances of getting yours reviewed too.
As a junior developer, you can let others know when you don’t understand part of the code, as it should be understandable by any developer in the team.
More about it in my post How to give code review as a junior developer?.
Code review’s goal is to check for bugs and edge cases, and challenge the implementation. It should neither be used to nitpick about minor formatting or styling preferences, nor for large-scale architectural discussions.
Use “why not” instead of “you should”, be open and positive and always suggest an alternative when you ask for a change.
Not all comments require a change, and not all asked changes are required for the PR to be approved. Be clear in your comment if the change isn’t urgent.
Before making your review public, re-read each comment: check for the tone you use and ensure you provide all the context to help the PR submitter.
You don’t want the reviewer to wait for your approval two days after they made all the changes you asked. When you review it, assume you’ll approve it as soon as all the fixes are made.
When a comment thread becomes a debate in your PR, you’d better cut it off and suggest to continue the discussion elsewhere, e.g. in a Slack thread. If necessary, dedicate a meeting to it, and/or involve a third-party.
That’s it! What did you think of these tips? Can you think of one tip you’d like to give other developers?
Share them here in comments 👇
If you liked these tips and want to learn some more, check out my book Pull Requests and Code Review, it’s free!
Also published here.