Code review checklist for junior developers
What senior engineers look for in a code review, as a practical checklist: correctness, edge cases, tests, naming, structure and performance, with C++-specific points.
Code review is where most junior developers learn the fastest, and where the same handful of comments come up again and again. Review your own work against this list before you ask someone else, and you'll skip most of them.
Correctness
- Does the code do what the ticket's acceptance criteria say, including the boundaries?
- What happens with empty input, the smallest and largest values, and invalid input?
- Can an operation fail halfway and leave the state broken? (Check first, change last.)
- Are rules enforced in one place, so no caller can bypass them?
Tests
- Is every acceptance criterion covered by a test?
- Is every boundary tested on both sides?
- Do the tests check behaviour rather than implementation details?
- Would a test fail if the feature were broken? (Try breaking it.)
More in unit testing in C++.
Naming and structure
- Do names say what something is or does, without needing a comment?
- Is each function doing one thing? Could a long one be split?
- Are magic numbers named constants (
kDailyCapCents, not1500)? - Is data validated at the edge, so the core only sees valid data?
Performance
- What's the complexity of each operation, and does it match the requirement?
- Is anything copied that could be passed by reference?
- Is there a loop inside a loop over the same data that a map would remove?
C++-specific points
- Is money in integer cents, never
double? - Are read-only methods
const, and parametersconst&orstd::string_view? - Does "maybe no value" use
std::optionalrather than a magic value like -1? See error handling in C++. - Does
std::map::operator[]accidentally insert keys during a lookup? - Is every resource owned by an object that releases it (RAII)? See RAII and smart pointers.
Practise with real checklists
Every Devventura milestone ends with a review checklist written by a senior engineer, with language-specific points. Good ones to start with: invoice totals for Ledgerly, password rules for Lockstep and the Shipwright order lifecycle.
Questions and answers
- How do I review my own code?
- Take a break first, then read the diff as if someone else wrote it, with a checklist. Run the tests, look for missing edge cases, and check every name says what the thing is.
- How should I respond to code review comments?
- Assume good intent, ask when a comment is unclear, fix what's right, and explain your reasoning when you disagree. Reply to every comment so the reviewer knows it was seen.
Practise it in a project
These projects put this guide to work, with tickets, tests and code review.
Ledgerly
Invoice totals for Ledgerly
Read amounts, compute net, VAT and gross totals to the cent, and never lose a cent to floating point.
- integer arithmetic
- rounding
- parsing
- exceptions
Lockstep
Password rules for Lockstep
Check new passwords against Lockstep's policy and a list of leaked passwords, and tell users every problem at once.
- character classes
- UTF-8 basics
- hash sets
- normalisation
Shipwright
Order lifecycle for Shipwright
Replace Shipwright's tangle of status flags with an explicit state machine: one transition table, guards, an audit history and replay from an event log.
- finite state machines
- transition tables
- guards
- event replay
Read next
- How to write a design doc: a short guide for junior developers
What a design document is for, a half-page template (components, data structures, trade-offs, open questions) and a worked example, before you write any code.