Operations · Operations & process management
Code review process
Best for Early Startup to Startup
Use it when
Every code change needs a second developer's approval before it merges, and reviews on your team are slow, inconsistent or argued over.
Skip it when
- Two developers can write the change together at one machine. Use Pair programming, which reviews the code as it is written.
- Merges keep breaking the shared build. Set up Continuous integration first, so every change arrives with a passing build and tests.
- You need to decide which documents the team keeps for people outside the code. Use Agile documentation, which this feeds.
- You need to find which part of delivery is slowest before changing how you review. Use DORA metrics for DevEx.
What to apply first and what to use instead are listed below.
Inputs
- ChangeOne self-contained change with its tests, usually around 100 lines, from the author's branch.
- Change descriptionWhat the change does and why, written by the author.
- Style guideThe team's written style guide for each language, which settles every style question it covers.
- ReviewersOne or more developers who own or know the code being changed, assigned by a code owners file or a team rota.
- Automated check resultsBuild, test and static analysis results for the change, from the CI service.
- Approval ruleThe number of approvals each protected branch requires before a merge, from the repository settings.
Steps
- Have the author split the work into small self-contained changes with tests, write the description, and send each change once its automated checks pass.
- Respond within one business day, at a break in your own work. If you cannot review it fully, say when you will or suggest another reviewer.
- Read the description and check that the change makes sense at all. Then review the main files for design, and send any major design comment straight away.
- Go through the remaining files in order, checking function, complexity, tests, naming, comments and style. Mark each comment as required, Nit, Optional or FYI, and say why.
- Have the author answer every comment with a code change or a reply, and rewrite unclear code instead of explaining it in the review tool.
- Approve once the change clearly improves the health of the code, even if it is not perfect. If author and reviewer cannot agree, talk it through live, write the outcome on the change, and escalate to the tech lead if needed.
Output
An approved change merged with its review record, kept in the review tool for each change.
- Change and description
- Reviewers and approvals
- Time to first response
- Comments by label (required, Nit, Optional, FYI)
- Rounds of review
- Disagreements escalated and how they were settled
- Merge date
Done when
- Every merged change has the number of approvals its branch rule requires.
- Every required comment is closed by a code change or a recorded reply.
- Every comment that is not required carries a label.
- The first reviewer response came within one business day.
- Every escalated disagreement has its outcome written on the change.
Measure
Each month, track time to first review response, rounds of review per change, change size and the share of changes merged within a day of being sent. Watch defects found after merge in reviewed code. Compare with your own previous three months. It is working when responses arrive within a business day, changes get smaller, and defects after merge hold steady or fall.
Hypothetical example
Fernbrook's mobile team had changes waiting four days for review, and authors kept rewriting code over style preferences. The team made its language style guide the only authority on style and set a one-business-day response rule. One author split a 1,200-line login rewrite into six changes of about 150 lines each. A reviewer spotted a design problem in the first change within hours, before the rest were built on it. Reviewers began marking small points as Nit. After two months, the median first response had fallen to five hours, and most changes merged after a single round of comments.
Common mistakes
- Holding a change until it is perfect. Approve once it improves the code's health, and mark polish points as Nit.
- Reviewing a very large change line by line. Ask the author to split it into small self-contained changes.
- Arguing over style the guide does not cover. Follow the style guide, and accept the author's choice where it is silent.
- Commenting on the developer instead of the code. Describe the problem in the code and say why it matters.
- Leaving a disagreement open in comments for days. Talk it through, record the result on the change, and escalate if needed.
Sources
- Google Engineering Practices Documentation: The standard of code review · Google, 2019
- Google Engineering Practices Documentation: Navigating a CL in review · Google
- Google Engineering Practices Documentation: Speed of code reviews · Google
Show all 7 sources
- Google Engineering Practices Documentation: How to write code review comments · Google
- Google Engineering Practices Documentation: Small CLs · Google
- Modern Code Review: A Case Study at Google · Caitlin Sadowski, Emma Söderberg, Luke Church, Michal Sipko and Alberto Bacchelli, 2018
- About pull request reviews · GitHub Docs
By company stage
Apply first
Nothing. You can start here.
Use instead
- Pair programming
Two developers can write the change together at one machine. Use Pair programming, which reviews the code as it is written.
- Continuous integration
Merges keep breaking the shared build. Set up Continuous integration first, so every change arrives with a passing build and tests.
- Agile documentation
You need to decide which documents the team keeps for people outside the code. Use Agile documentation, which this feeds.
- DORA metrics for DevEx
You need to find which part of delivery is slowest before changing how you review. Use DORA metrics for DevEx.
Where it sits
Open the operations & process management roadmapRecommended resources
No sponsored resources on this framework yet. Sponsored listings would be labelled here, never in search.
Progress is not saved until you have an account. Create a free account