Running a Structured Code Review Under Time Pressure
System DesignModel answerLast updated
Walk through a repeatable framework for producing high-signal PR feedback — prioritized, clearly labeled, and written with minimal context — in roughly 20–30 minutes.
The Scenario
You are given a short code change — a diff, a pull request, or a standalone function — and asked to produce written review comments with minimal back-and-forth. The interviewer hands you the code, gives you a few minutes to read, and then largely goes quiet. The deliverable is the set of comments you would actually leave on a real PR, not a verbal summary.
Walk through your structured approach to producing useful, well-prioritized review feedback under these conditions.
What to Cover
Your answer should concretely address:
- The categories of issues you scan for (correctness, edge cases, concurrency, security, performance, readability, testing, API design, observability, etc.) and the order you apply them.
- How you label and prioritize comments so the author immediately knows what is a blocker versus a suggestion versus a minor polish item.
- Examples of well-written comments — the exact phrasing you would type for a blocker, a suggestion, and a nit.
- How you handle missing context when you cannot ask the author or look up the ticket.
Constraints and Assumptions
- Written format, little dialogue. You should narrate your thinking aloud, but the real output is the comments themselves.
- Time-boxed at ~20–30 minutes. Enough for a careful read and a focused, prioritized set of comments — not an exhaustive line-by-line audit.
- Limited context. No surrounding codebase, no ticket, no author to ping. Make assumptions explicit rather than stalling.
- Language-agnostic. The framework should apply regardless of what language appears in front of you.
Clarifying Questions Worth Asking First
Before reading a single line of code, briefly confirm scope:
- What is the goal of this change — is there a linked ticket or intended behavior I should review against?
- What style of feedback do you want — line-level comments, an overall summary, or both? Should I flag missing tests?
- Are there non-functional constraints that matter here — latency budget, PII sensitivity, backward-compatibility requirements?
- Is this change on a hot path or public API, or internal and low-traffic? That calibrates how strict I should be.
- What is the team's approval bar — must everything be resolved before merge, or is "approve with comments" acceptable?
Hints
Hint 1
Start with the highest-stakes categories first — correctness and security — before you spend any time on naming or formatting. A beautifully styled function that silently drops data is still a blocker.
Hint 2
Your label system does more work than you might expect. If every comment looks the same weight, the author doesn't know what to fix before merging versus what to address later. Pick explicit prefixes — BLOCKER, SUGGESTION, NIT — and use them consistently.
Hint 3
When context is missing, don't stall and don't guess silently. State your assumption inline ('Assuming this runs in a single-threaded context — if not, see note below') so the author can correct the assumption rather than miss the concern entirely.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
What a Strong Answer Looks Like
The interviewer is not grading you on whether you can recite every possible issue category. They are watching your judgment — do you go after the right things first, can you communicate feedback a real teammate would find useful, and do you stay productive when context is thin?
Step 1 — Ask Scope Questions Before Reading
Spend 60–90 seconds confirming a few things before diving in. This is not stalling; it is calibration.
- Is there a ticket or acceptance criteria to review against?
- Is this on a hot path, a public API, or internal-only?
- What is the merge bar — hard block, or approve with comments?
If the interviewer says "just dive in," that is fine — note that you are making assumptions, then proceed.
Step 2 — First Read: Get the Mental Model
Read the entire diff once without writing anything. You are answering: what is this change trying to do? Understanding intent protects you from flagging deliberate decisions as bugs and from missing real bugs because you dove into line-level detail too early.
Step 3 — Second Pass: Categories in Priority Order
Work through categories from highest stakes to lowest. Stopping early if time runs out means you have covered the most important ground.
1. Correctness and logic — Does the code do what it claims? Look for off-by-one errors, wrong boolean conditions, misused APIs, incorrect assumptions about return values, and silent failures (swallowed exceptions, ignored error returns).
2. Edge cases and input validation — What happens with null, empty input, zero, negative numbers, max values, or concurrent writes? These are frequent interview catches because authors often test the happy path only.
3. Security — Is there unsanitized input going into a query, a log, or an external call? Are secrets handled correctly? Is there an authorization check that should exist but doesn't? On a public API, this category deserves extra time.
4. Concurrency and state — Is mutable shared state accessed without synchronization? Is there a race between a check and an action (TOCTOU)? Does the code assume single-threaded execution without documenting that assumption?
5. Performance — Is there an O(n²) operation hiding inside a loop? Are there unnecessary database calls that could be batched? Flag this only if the code is on a hot path — don't over-engineer a utility function called once at startup.
6. Tests and observability — Are the added tests actually testing the new behavior, or just the happy path? Is there a new failure mode with no log line or metric, making it invisible in production?
7. API and contract design — Does the function signature make it easy to call correctly and hard to call wrong? Would a caller know what to do with the return value?
8. Readability, naming, style — Variable names, comment quality, dead code. These are nits unless the code is a public API where naming becomes part of the contract.
Step 4 — Label Every Comment Explicitly
Use consistent prefixes. Authors should never have to guess what they must fix before merging.
- BLOCKER: Must be resolved before this merges. Reserved for correctness bugs, data loss, security issues, or broken contracts.
- SUGGESTION: Worth fixing but not a merge gate. Covers better approaches, missing edge case handling, testability improvements.
- NIT: Small polish item. Naming, formatting, a redundant comment. The author can fix it now or defer it.
Step 5 — Write Comments That Are Specific and Actionable
Each comment should say: what the issue is, why it matters, and what a fix looks like. Vague comments waste the author's time.
Example of a blocker:
BLOCKER:
getUser()can returnnullwhen the session has expired (see the AuthService contract), but this line dereferences the result directly without a null check. If called post-expiry this will throw aNullPointerExceptionand the request will return a 500. Suggest either guarding with an explicit null check and returning a 401, or usingOptional<User>consistently with the rest of the service layer.
Example of a suggestion:
SUGGESTION: The retry loop runs up to 5 times with no backoff. Under a thundering-herd scenario this could amplify load on the downstream service. Consider exponential backoff with jitter — even a simple
Thread.sleep(100 * attempt)would reduce the spike meaningfully.
Example of a nit:
NIT:
tempandtemp2don't communicate intent.candidateScore/bestScorewould make the comparison on line 42 self-documenting.
Notice the tone: direct about the problem, specific about the risk, concrete about the fix, and written with the assumption that the author has good intentions.
Step 6 — Handle Missing Context Without Stalling
When you cannot look something up, make the assumption explicit in the comment itself.
SUGGESTION (assumption): I'm assuming this endpoint is internal and not reachable by untrusted clients. If that changes, the input to
buildQuery()will need sanitization — marking this as a suggestion rather than a blocker on that basis.
This surfaces the concern, documents your reasoning, and lets the author correct the assumption if it is wrong.
Common Mistakes to Avoid
- All comments look equal in weight. Without labels, authors guess what to prioritize and often fix nits and miss blockers.
- Only catching style issues. If your only comments are about naming and formatting, you have not demonstrated engineering judgment.
- Blocking on things you can't verify. If you genuinely cannot tell whether a race condition is possible without seeing the caller, say so — don't omit the concern, but label it appropriately.
- Proposing a complete rewrite. Review the change in front of you. Systemic refactoring comments belong in a follow-up ticket, not as a blocker on an unrelated PR.
- Forgetting tests and observability. These are the categories most candidates skip because they feel less concrete — and therefore the ones that signal seniority when you do cover them.