
No one knows your changes better than yourself. The less code in your code reviews, the more thorough your reviewers can be.
Avoid asking reviewers to stare at your code for hours. Ask them to do 500 lines, and they’ll say, “It looks good.” Ask a programmer to review 10 lines of code, and they’ll find 10 issues. The benefit here is clear: Smaller code reviews get more thorough reviews. Keep your commits and pull requests clean and brief, and your reviewers will be much more effective. If you want quality code reviews, don’t overwhelm your reviewers with hours of changes to stare at. There’s nothing worse than opening up a code review and seeing that it has touched hundreds of files and thousands of lines. Making commits for logically independent changes facilitates navigating through a pull request and also doubles as a good summary of what work was done. Only commit what matters–every line changed is a step toward a fix or feature. 1 issue in bug tracker = 1 pull request. Ensure each commit builds successfully. Strive for one major change per commit. This makes debugging and bisecting on old changes much easier. Writing good commits also discourages the habit of making commits that fail builds, even if the overall pull request builds just fine. Modular commits result in cleaner git history. The benefits also extend beyond the code review. The benefits are straightforward: Bite-sized, organized code reviews are easier for the reviewers to follow and result in more thorough reviews overall.
Just as a good function or class has a single, clear, straightforward purpose, a good commit or pull request solves one clear problem and does it well. Minimize the features in one pull request When was the last time you had a truly quality code review? Have you ever been frustrated by reviewing someone else’s code? In this two-part series, we will cover several pieces of advice that all of us–reviewers and code writers alike–can implement to make the whole code review process as efficient and painless as possible. “After experiencing the benefits of peer reviews for nearly fifteen years, I would never work in a team that did not perform them.” -Karl Weigers, “Humanizing Peer Reviews” This is part 1 of a 2-part series on code reviews. However, the code review is a very powerful tool if utilized correctly and can result in substantial benefits for relatively little investment as long as we are willing to invest a bit of time into it. As a result, we often view them as a mundane task to check off the list–a final gatekeeper before our wonderful features or bug fixes can begin their journey into the wild to be enjoyed by users.
Code reviews: Some love them, some hate them, but most probably see them as no better than a necessary evil.