Skip to content

Engineering habits · Part 3 of 10

What to look for in a code review

A good review checks correctness, design, tests and clarity, in that order of importance, and is kind. A checklist for reviewers and authors.

· 2 min read

engineeringcode-review

Code review has two goals: catch problems before they reach users, and spread knowledge across the team. Style arguments are the least valuable part of it.

Review in layers

  1. Purpose: does the change solve the stated problem? Is anything missing or extra?
  2. Correctness: edge cases, error handling, off-by-one mistakes, concurrency, null values, time zones.
  3. Design: is the code in the right place, with sensible names and boundaries? Will it be easy to change?
  4. Tests: do they cover the behaviour and the failure paths? Would they fail if the code were wrong?
  5. Security and privacy: validation of input, authorisation, secrets, personal data in logs.
  6. Operations: migrations safe to run, performance on large data, monitoring, rollback plan.
  7. Readability: could a newcomer understand it without the author?

Leave formatting to automatic tools such as linters and formatters, so humans spend attention on the layers above.

Writing good comments

  • Ask questions instead of issuing orders: "What happens if the list is empty?"
  • Explain the reason, and suggest an alternative when you can.
  • Mark importance. Label nits as optional so the author knows what must change.
  • Praise good solutions. Review is also where people learn what good looks like.
Ruby
# A reviewer's eye catches this: the divisor can be zero.
def average(values)
  values.sum / values.size
end

puts average([2, 4, 6])

As an author

  1. Keep the change small and self-explanatory, and describe it.
  2. Run tests and linters before asking for review.
  3. Treat comments as feedback about the code, not about you.
  4. If you disagree, discuss it, and ask a third person when stuck.

Speed matters

A review that waits for days blocks work and encourages large batches. Agree on a target, such as a first response within one working day.

Takeaway

Review for purpose, correctness and design first, automate style, write comments that teach, and keep the whole process quick and respectful.

A knowledge article, drafted with AI assistance and checked with automated tests. It is general background, not a description of my own experience or of any client's work.

Comments

Leave a comment

No account or email needed. Comments appear after review. A one-way hash of your IP address is kept for 30 days to fight spam, then erased.