Applied Design and Code Review: Worked Examples
Work through each trace before reading the explanation. Then solve the transfer task without the page open.
Example 1: A shorter patch can have a larger risk
A patch replaces “fetch user by tenant and ID” with “fetch user by ID.” It removes an argument and simplifies the call but may permit cross-tenant access.
Review the contract first: does identity include tenant scope, and where is authorization enforced? A regression test uses identical local IDs in two tenants and expects separation. Formatting comments are secondary until this behavior is established.
Example 2: Make a redesign reviewable
A change renames methods, moves files, and changes retry behavior together. A reviewer cannot easily tell which differences are mechanical and which affect outcomes.
Split behavior-preserving renames from the retry change. For the latter, show a failing scenario, bounded-attempt expectation, and effect-count assertion. Small commits improve causal explanation; they are not valuable merely because they are small.
Transfer and self-check
A reviewer asks for a factory but gives no failure or change scenario. What evidence would justify it? Check: multiple construction policies, ownership rules, or test seams that the factory would simplify.
Evidence to keep
Save your first attempt, corrected reasoning, and transfer result as checkpoint evidence. A matching final answer without an explanation is insufficient. Continue with the guided lab and use the reading guide to repair a specific gap.