Code reviews people actually read

Practices2 min read

Two people working at a table with laptops
Photo: Priscilla Du PreezUnsplash

A code review is useful when the author reads the comments, understands them and changes something. Many reviews fail at the first step: the pull request is too big to review properly, or the comments are too vague to act on. These are the habits that make reviews work for me, on both sides.

As the author

Keep pull requests small. Under about 400 changed lines, reviewers read the code. Above that, they skim it. If a feature is large, split it: the migration first, then the domain change, then the endpoint, then the UI.

Write the description for someone who missed the meeting. What changed, why, and how you tested it. A screenshot for UI changes. A note on anything you were unsure about, so the reviewer knows where to look.

Review your own diff first. Most leftover debug logs, commented-out code and unrelated formatting changes are caught by reading your own pull request before asking anyone else to.

As the reviewer

Separate what blocks from what doesn't. I prefix comments so the author can sort them quickly:

  • blocking: a bug, a security problem, or something that breaks a contract.
  • suggestion: a better approach I would like considered.
  • nit: style or naming. Fine to ignore.
  • question: I don't understand something yet.

Say why, not just what. "Use AsNoTracking() here" is an instruction. "This query only reads, so AsNoTracking() skips change tracking and saves memory on large lists" is something the author can apply next time without you.

Comment on the code, not the person. "This method does three things" lands better than "you made this method too long", and it is more precise.

Approve when it is good enough. A review is not a chance to rewrite the code the way you would have written it. If it is correct, readable and tested, approve it and leave the rest as suggestions.

As a team

  • Automate style. Formatters and linters in CI end most arguments about spacing and naming before a human sees the code.
  • Agree on a response time. A pull request that waits two days goes stale and gets merged with conflicts. Within one working day is a reasonable target.
  • Rotate reviewers. It spreads knowledge of the codebase and stops one person from becoming the bottleneck.

For people learning

When I review code from students or junior developers, I add one more rule: every blocking comment links to a reason, such as a doc page, a test that fails, or an example. The goal of the review is that they need fewer comments next time, and that only happens when they understand the reason behind each one.

Have a platform in mind?

Tell me who will use it and what they need to do. I'll reply with questions and next steps.

Join the conversation

No comments yet. Be the first to share your thoughts.

Leave a comment

Questions, ideas or a different point of view are all welcome. Your comment will appear here once it has been approved.

Your email is never shown publicly. It is only used if you ask to be told about a reply.