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
- Purpose: does the change solve the stated problem? Is anything missing or extra?
- Correctness: edge cases, error handling, off-by-one mistakes, concurrency, null values, time zones.
- Design: is the code in the right place, with sensible names and boundaries? Will it be easy to change?
- Tests: do they cover the behaviour and the failure paths? Would they fail if the code were wrong?
- Security and privacy: validation of input, authorisation, secrets, personal data in logs.
- Operations: migrations safe to run, performance on large data, monitoring, rollback plan.
- 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.
# 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
- Keep the change small and self-explanatory, and describe it.
- Run tests and linters before asking for review.
- Treat comments as feedback about the code, not about you.
- 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.
Comments