Book Deep-Read · Software Engineering at Google · Chapter 9

Code Review

Software Engineering at Google · Ch 9 · Code Review · Tom Manshreck & Caitlin Sadowski · 2020

中文 →

What is this chapter about?

Every line of code behind Google Search or YouTube was read and approved by at least one other engineer before it went in. That rule is called code review: you can't drop your code straight into the company's giant shared repository; a colleague has to look at it first. This chapter is about how Google does it, and what it really buys.

An analogy

Think of a newspaper. A reporter files a story and an editor reads it: the editor catches typos and checks facts, but more importantly makes sure readers will understand it. The section chief has to agree the piece belongs in their section, and a veteran copy editor checks it matches the paper's house style. All three can be the same person, but all three questions must be answered.

A strange thing first

Most people assume review is mainly for catching bugs. Yet Google's own research found the biggest payoffs are the invisible ones: making sure at least two people understand the code, keeping the whole company writing it the same way, and letting newcomers learn the ropes one review at a time. Catching bugs is just one item on the list.

Why the old world was hard

Code is written once but read and changed by many people for years. If only the author understands it, the moment the author changes teams it becomes a black box nobody dares to touch. With tens of thousands of people each writing their own way, the codebase slowly turns into a jumble.

How it works, intuitively

What it buys you / how to choose

Should your team review code? If the code will live for years and more than one or two people maintain it, yes; the trick is to keep changes small and replies fast. The honest cost: review takes every engineer several hours a week, and when it's slow, people get frustrated waiting.

Remember it in one line

Review isn't about catching culprits; it's about making sure every line of code is understood by at least two people.

Want the full review flow, the three approvals (LGTM, owner, readability), the five benefits, the five best practices and how the four kinds of review differ? → Switch to the deep read