awesome-everything RU
↑ Back to the climb

Engineering Practice

Code review: reading diffs and comments

Crux Read real diffs, a PR description, and review comments — spot the design bug a reviewer must catch, judge a PR's reviewability, and rewrite a comment so it states severity and a fix.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 14 min

Review is read, not recited. Here are the artifacts you actually face in a PR — a diff, a description, a thread of comments. For each, do what a senior reviewer does: find the defect that tooling can’t, judge whether the change is even reviewable, and turn a vague comment into one the author can act on.

Goal

Practise the reviewer’s loop on real material: separate the undecidable design flaw from the mechanical noise, read PR shape for reviewability, and write feedback that answers how important and what to do.

Snippet 1 — the retry path a reviewer must catch

# PR: "Add billing retry on transient gateway errors"
def charge_customer(order_id, amount):
    record = db.insert_charge(order_id=order_id, amount=amount, status="pending")
    for attempt in range(3):
        resp = gateway.charge(amount)          # may time out AFTER charging
        if resp.ok:
            db.update(record, status="settled")
            return resp
        time.sleep(2 ** attempt)               # back off and retry
    db.update(record, status="failed")
    raise ChargeError(order_id)
Quiz

CI is green — format, lint, types, and the unit tests all pass. What is the defect review exists to catch here?

Snippet 2 — the PR description

Title:  Refactor checkout + add coupons + migrate orders table
Files changed: 47   +1,812  −940
Description: "Cleaned up checkout, added coupon support, and migrated the
orders table to the new schema. All in one PR so it deploys atomically."
Quiz

As the assigned reviewer, what is the senior response to this PR before reading a single line of the diff?

Snippet 3 — a review comment

Reviewer comment on a 40-line PR, left as one line on the file:
  "this is confusing, why did you even do it this way"
Quiz

Why will this comment generate friction, and what is the minimal rewrite that fixes it?

Snippet 4 — the diff that should never reach a human

- const  userName=req.body.userName
+ const userName = req.body.userName;
- function getUser( id ){return db.find(id)}
+ function getUser(id) { return db.find(id); }
Quiz

These are the only changes in a PR, and a reviewer spent ten minutes hand-checking the spacing and semicolons. What does this reveal about the pipeline?

Recap

Reading is the job: a green CI and passing tests don’t certify the money path, so the reviewer hunts the undecidable defect — here, a non-idempotent retry that double-charges. PR shape is read before the diff: a 1,812-line, three-concern change gets split or stacked because attention won’t scale to it. Comments are judged by whether they state severity and a fix and aim at the code, not the author. And a diff full of spacing fixes hand-checked by a human is a missing formatter gate — the decidable class should never reach review. Diagnose from the artifact, fix at the right layer, keep human attention on what only a human can decide.

Continue the climb ↑Code review: redesign a review process
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.