📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

How do you give and receive code review well? What do you actually look for in a review, how do you word comments so they help rather than hurt, and how do you separate blocking issues from suggestions?

Covers what a reviewer checks (correctness, design, tests, security, readability), how to write kind and specific comments, labelling blocking versus non-blocking feedback, and how to receive review without defensiveness.

Intermediate Theory Intermediate code-quality code-review collaboration communication engineering-practice pull-requests

🎯 Key points

  • Review order: correctness and security, then design, tests, then readability
  • Correctness means checking edge cases against the tests: empty, null, boundary, retry, concurrency
  • Automate style with dotnet format and analysers; follow the team's written review guide
  • Comment on the code, not the person; ask questions, explain why
  • Label comments: blocking, suggestion, nit, question (Conventional Comments)
  • Approve with minor comments instead of blocking on taste; respond within a working day
  • Receiving: assume good intent, reply to every comment, move long debates to a call
  • Senior reviewers mentor through review and turn repeated comments into conventions

⏱ 30-second answer

Good review is about finding real problems and sharing knowledge without slowing the team.

  • What I look for, in order: correctness and edge cases, security and data handling, design and fit with the codebase, tests, then readability and naming. Style is the analyser's job, not mine.
  • How I word it: about the code, not the person, with the reason: "This query runs once per order line, so 500 lines means 500 round trips. Could we load them in one query?"
  • Blocking vs suggestion: I label every comment (blocking, suggestion, nit, question) so the author knows what must change before merge.
  • Receiving: assume good intent, answer every comment, and take long debates to a quick call.

The trade-off is thoroughness against flow: block only on what matters, and approve with comments for the rest.

🗣 Full answer (senior)

How I would answer this in an interview

"I treat code review as two jobs: catching problems before they reach production, and spreading knowledge across the team. So I review in priority order. First correctness: does it do what the ticket says, what happens on nulls, empty lists, retries and concurrency? Then security and data: is input validated, is anything personal being logged, is authorisation checked? Then design: does it fit the existing patterns, is the responsibility in the right place? Then tests, and only then readability and naming. Formatting and simple style rules I leave to dotnet format and analysers in CI, because a human arguing about brace placement is wasted time.

How I word comments matters as much as what I find. I comment on the code, not the person, I give the reason, and I often ask a question rather than issue an order: 'What happens here if the payment gateway times out? I think we'd charge twice on retry.' I label every comment, using something like Conventional Comments: blocking, suggestion, nit, question. That way the author knows exactly what has to change before merge and what's my taste. If the only things left are nits, I approve with comments rather than holding the PR hostage. I also call out good work specifically, because review shouldn't only be a list of faults.

On the receiving side, I assume good intent, reply to every comment, either fixing it or explaining why not, and if a thread goes past two rounds I suggest a ten-minute call and write the outcome back into the PR. The mistake I see is reviewers blocking on personal preference and authors taking comments personally. The goal is better code merged sooner, not winning the thread."


What to look for, in priority order

Priority Look for Example comment
1. Correctness Edge cases, nulls, concurrency, error handling "If items is empty this divides by zero."
2. Security and data Validation, authorisation, secrets, PII in logs "This logs the full customer record, including email."
3. Design Responsibility, coupling, fit with patterns "Should pricing live in OrderController?"
4. Tests Behaviour covered, meaningful assertions "No test for the GST-free case."
5. Readability Names, structure, comments that explain why "Process2 doesn't tell me what it does."

Comment labels

Label Meaning Blocks merge?
blocking Bug, security issue, broken contract Yes
suggestion Better approach; author decides No
nit Minor style or taste No
question I don't understand; please explain Only if the answer reveals a problem
praise This is good, keep doing it No

Harsh versus helpful

Harsh Helpful
"This is wrong." "blocking: this runs a query per line, so 500 lines means 500 round trips. Could we Include them or load in one query?"
"Why would you do it like this?" "question: what made you choose a static helper here? I'm wondering about testing it."
"Bad name." "nit: data could be pendingInvoices, so the loop reads clearly."

Production example

A team I worked with had PRs sitting for two to three days because reviewers blocked on style debates. After adding dotnet format and analysers to CI, adopting comment labels and agreeing on a one-working-day response target, time to first review fell from about 20 hours to about 4, and the number of review rounds per PR dropped from three to one or two.

🔍 What the interviewer is checking

Checks whether the candidate can find important problems and also work well with people, both as reviewer and as author.

Green flags

  • Has a priority order with correctness and security first
  • Automates style instead of commenting on it
  • Labels comments and distinguishes blocking from suggestions
  • Gives an example of kindly worded, specific feedback
  • Receives feedback without defensiveness and moves long debates offline

Red flags

  • Review is mostly about formatting or personal style
  • Blunt or sarcastic comment examples
  • Never approves until everything matches their preference

📚 Learn in depth

1. Why review exists

Review has three outcomes: defects caught before production, shared understanding of the codebase (bus factor), and consistent design. Studies of review at Microsoft found that knowledge transfer and finding better solutions are as valuable as catching bugs, and that most review comments concern maintainability rather than functional defects.

2. A review pass, step by step

1. Read the description and ticket  -> do I understand the goal?
2. Read the tests                    -> what behaviour is promised?
3. Read the main change              -> correctness, security, design
4. Read the rest                     -> wiring, config, migrations
5. Write comments, label each one
6. Decide: approve / approve with comments / request changes

Reading the tests first gives you the specification before the implementation.

3. What automation should catch instead of you

Concern Tool
Formatting, using order, var style .editorconfig + dotnet format --verify-no-changes
Nullable, async misuse, disposal Roslyn analysers (CA rules), warnings as errors
Vulnerable packages dotnet list package --vulnerable, Dependabot
Coverage on new code, duplication SonarQube quality gate

Every automated rule removes a category of human nitpicks.

4. The psychology of comments

Written comments lose tone, so neutral text reads as harsh. Techniques that help: talk about the code ("this method") not the person ("you"); use "we"; ask questions when you're unsure; give the reason and, where useful, a suggested fix; and say what's good. Conventional Comments formalises labels like suggestion (non-blocking):.

5. Receiving review

Separate yourself from the code. Reply to every comment: fixed, or why not. If you disagree, explain once with evidence; if it's still unresolved, talk live and record the outcome. Don't silently ignore comments, and don't resolve someone else's thread without a reply.

6. Speed matters

A slow review blocks the author, encourages bigger PRs ("might as well add more while I wait") and increases merge conflicts. Google's engineering practices recommend responding within one business day at most. Small PRs plus fast reviews is a reinforcing loop.

Try it yourself

  1. Take one of your old review comments and rewrite it with a label, a reason and a suggested fix.
  2. Review a PR by reading the tests first and note whether it changes what you find.
  3. List the last 20 nit comments on your team's PRs; which could an analyser or .editorconfig rule catch?
  4. Measure time to first review on your repo for a month using the GitHub or Azure DevOps API.
  5. Write a one-page team review guide: priorities, labels and response time.

💻 Code

A review comment on real code, written the way I'd leave it, followed by the change the author made.

// Under review: loads each customer inside the loop.
namespace Billing;

public sealed class InvoiceRunner(BillingDbContext db, IInvoiceSender sender)
{
    public async Task RunAsync(CancellationToken ct)
    {
        var due = await db.Invoices.Where(i => i.Status == InvoiceStatus.Due).ToListAsync(ct);
        foreach (var invoice in due)
        {
            // blocking: this is one query per invoice. With ~3,000 due invoices at month end
            // that's 3,000 round trips. Could we load customers with the invoices in one query?
            var customer = await db.Customers.SingleAsync(c => c.Id == invoice.CustomerId, ct);
            await sender.SendAsync(invoice, customer.Email, ct);
        }
    }
}
// After review: one query, projected to just what is needed.
namespace Billing;

public sealed class InvoiceRunner(BillingDbContext db, IInvoiceSender sender)
{
    public async Task RunAsync(CancellationToken ct)
    {
        var due = await db.Invoices
            .Where(i => i.Status == InvoiceStatus.Due)
            .Select(i => new { Invoice = i, i.Customer.Email })
            .ToListAsync(ct);

        foreach (var item in due)
        {
            await sender.SendAsync(item.Invoice, item.Email, ct);
        }
    }
}

Style is enforced by the build, not by reviewers:

dotnet format --verify-no-changes   # fails CI if formatting differs from .editorconfig

⚠ Common mistakes

  • Mistake: Spending review comments on formatting and style. Why it is wrong: It burns attention and goodwill on things a tool can enforce. Instead: Enforce style with .editorconfig, dotnet format and analysers in CI.
  • Mistake: Reviewing against your personal standards instead of the team's. Why it is wrong: Authors get contradictory feedback depending on who reviews, and conventions the team agreed on (architecture layers, error-handling style, the analysers it adopted) get ignored. Instead: Review against the team's written guide and conventions; if you want a new rule, propose it to the team rather than enforcing it in one PR.
  • Mistake: Checking only the happy path for correctness. Why it is wrong: Most production bugs live in empty inputs, boundaries, retries and concurrent updates. Instead: For each changed branch ask which test covers the edge case, and ask for one if none does.
  • Mistake: Unlabelled comments. Why it is wrong: The author can't tell a security bug from a taste preference and either over-fixes or ignores both. Instead: Label comments blocking, suggestion, nit or question.
  • Mistake: Commenting on the person ("you always..."). Why it is wrong: It makes people defensive and they stop asking for review early. Instead: Talk about the code and give the reason.
  • Mistake: Blocking a PR on personal preference. Why it is wrong: It slows delivery and teaches people that review is about the reviewer's taste. Instead: Approve with non-blocking suggestions.
  • Mistake: Letting a PR wait days for review. Why it is wrong: It blocks the author, causes conflicts and pushes people towards bigger PRs. Instead: Agree a response time, such as within one working day.
  • Mistake: Long back-and-forth threads in text. Why it is wrong: Tone degrades and nothing gets resolved. Instead: After two rounds, talk for ten minutes and write the outcome in the PR.
  • Mistake: Only pointing out problems. Why it is wrong: People don't learn what good looks like and review feels hostile. Instead: Call out good decisions specifically.

🏛 Senior insight: trade-offs

The reviewer has power in the conversation, so the reviewer sets the tone. A senior engineer uses review to teach, not to gatekeep: explaining the why, linking to an example elsewhere in the codebase, and offering to pair when a PR shows someone is stuck. With a junior developer I'll often leave fewer, higher-value comments and fix one example together on a call rather than drop twenty comments on them. I also invite juniors to review my PRs, because reading senior code with permission to ask questions is one of the fastest ways to learn.

Seniors also work at the team and cross-team level. When the same comment appears in several reviews, that's a missing convention: I write it into the team's review guide, an .editorconfig rule or an analyser, so nobody has to write it again. For changes that touch another team's service or a shared library, I add a reviewer from that team and agree the contract in the PR, rather than discovering the disagreement after release.

Approach When it fits Cost When not to
Async PR review Most changes Hours of latency Urgent fixes or deep design disagreements
Pair or mob review Complex or risky change; onboarding Two people's time Trivial changes
Two approvers / CODEOWNERS Security-sensitive, payments or shared code Slower merges Everyday code
Approve with comments Only nits or suggestions left Trusting the author Blocking issues remain

🔗 Follow-ups the interviewer may ask

  1. When: Candidate says style should be enforced by tooling, not reviewers. Why: Checks they know how .editorconfig and dotnet format actually enforce style in the build.
    How to answer

    I commit an .editorconfig at the repo root with root = true. It holds formatting (indentation, new lines), .NET code style preferences such as file-scoped namespaces, and severities for analyser and code style rules via dotnet_diagnostic.<id>.severity. Visual Studio, VS Code and Rider all read it, so style no longer depends on the editor. To enforce it, I set EnforceCodeStyleInBuild so IDE rules run during dotnet build, and run dotnet format --verify-no-changes in CI.

  2. When: Candidate talks about what they look for in a review. Why: Checks they can apply review priorities to real code and decide what to fix now versus log as debt.
    How to answer

    I'd read it for risk first, style last. Ranked:

    1. Correctness/security: an email sent before SaveChangesAsync (customer told they're signed up when the save can fail), and personal information (email, date of birth) logged and exported unmasked, a Privacy Act issue.
    2. Wrong data: loyalty points calculated with duplicated, slightly different logic in two methods.
    3. Design smells: god class (four responsibilities), long method, primitive obsession (string email, Guid IDs), feature envy on Customer, dead code.

    My rule: block on anything the PR introduces or touches that is a correctness or privacy risk; suggest small fixes in lines the PR changes; log as debt pre-existing structural smells with a ticket that says what they cost. The trade-off is merging safe code today without turning one PR into a rewrite.

↩ Usually asked after

More in Engineering Practice

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me