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

📚 Interview question

Design a definition of done for a .NET product team that actually raises quality without slowing delivery. What goes in it, what do you automate versus check by hand, how does it differ for different kinds of work, and how do you stop it becoming a box-ticking exercise?

Covers designing a team definition of done: quality criteria (tests, review, analysers, security, observability, docs, deployed to production), automating checks in CI and branch policies, keeping it short, tailoring by work type, and evolving it with retros and metrics.

Senior Architecture Advanced agile ci-cd code-quality definition-of-done engineering-practice quality-gates

🎯 Key points

  • DoD = shared quality bar for every increment (Scrum), distinct from per-story acceptance criteria
  • Short list (6-10 items), each verifiable; done means deployed and observable, not 'merged'
  • Automate what you can: build, tests, coverage on new code, analysers, vulnerable packages, dotnet format, in CI and branch policies
  • Humans check what tools can't: review for design and security, acceptance criteria, docs/ADR when relevant
  • Include operability: logging, metrics, alerts, feature flag and rollback plan
  • Security and privacy items: no secrets, PII handling, threat model for sensitive changes (Privacy Act, Essential Eight)
  • Tailor by work type (feature, bug, spike, infra) without weakening the core
  • Evolve it in retros using DORA metrics and escaped defects; remove items that don't earn their cost

⏱ 30-second answer

A definition of done is the team's shared quality bar for every piece of work, separate from a story's acceptance criteria. I keep it short (6–10 items) and verifiable, and I make done mean deployed and observable in production, not merged.

  • Automate everything a tool can check, as CI gates and branch policies: build, unit and integration tests, coverage on new code, analysers as errors, vulnerable-package scan, dotnet format.
  • Humans check what tools can't: a code review for design and security, acceptance criteria demoed, docs or an ADR where relevant.
  • Include operability: logs, metrics and alerts for new behaviour, and a rollback or feature-flag plan.
  • Evolve it in retros with DORA metrics and escaped defects.

The trade-off: every item costs time on every story, so each one must earn its place by preventing real defects or incidents.

🗣 Full answer (senior)

How I would answer this in an interview

"I'd start by being clear on what a definition of done is: the quality bar every increment meets, regardless of the story. Acceptance criteria say what this story does; the DoD says how well everything is done. The design principle is that a good DoD makes the right thing the easy thing. So I keep it short, around six to ten items, every item checkable, and I push as much as possible into automation, so it doesn't add meetings or checklists to every story.

Concretely, the automated part lives in the pipeline and branch policies: the build passes with analysers at warnings-as-errors, unit and integration tests pass, coverage on new code meets a threshold in SonarQube, dotnet format reports no changes, there are no vulnerable packages, and the PR has an approving review. The human part is short: acceptance criteria demonstrated to the product owner, a review that looked at design and security, an ADR or runbook update when the change warrants it, and observability: new behaviour has logs, metrics and an alert where it matters. And done means in production, behind a feature flag if needed, with a rollback path. For example, at [company] we [changed done from 'merged' to 'deployed and verified in production'], and [escaped defects fell by about a third over two quarters] because problems surfaced while the developer still had context.

To stop it becoming box-ticking, I tailor it by work type: a spike's done is a written finding, not tests; an infra change needs a plan in Bicep or Terraform reviewed. I review it in retros every quarter using DORA metrics and escaped defects, and remove items that don't prevent anything. The mistake I see is a 25-item checklist nobody reads, or a DoD that stops at 'code reviewed', which leaves testing and operations as someone else's problem."


A definition of done for a .NET product team

# Item How it's verified
1 Builds with no warnings (analysers as errors) CI build
2 Unit and integration tests pass; new code coverage ≥ 80% CI + SonarQube quality gate
3 No formatting drift, no vulnerable packages dotnet format --verify-no-changes, dotnet list package --vulnerable
4 Reviewed and approved (design, security, tests) Branch policy: 1 approval, 2 for payments code
5 Acceptance criteria demonstrated PO sign-off on the work item
6 Observable: logs, metrics, alert where it matters Review checklist item; dashboard link in PR
7 Docs updated: API spec, runbook, ADR if architectural Review checklist item
8 Deployed to production (flag off is OK) with a rollback path Pipeline release record

Automated versus human

Check Automated Human
Compiles, tests, coverage ✔
Style and analysers ✔
Vulnerable or disallowed packages, secrets ✔
Design fit, naming, correctness of approach ✔
Security and privacy reasoning Partly (SAST) ✔
Meets the user need ✔

Tailoring by work type

Work type Done also means Not required
Feature Flag strategy, metrics for adoption
Bug fix A regression test that failed before the fix
Spike A written finding or ADR Production-quality code, tests
Infrastructure IaC change reviewed, what-if / plan output attached Unit coverage

Production example

A team's DoD ended at 'merged to main'; releases were fortnightly and about one in five caused a hotfix. Moving to a DoD that ended at 'deployed and verified in production', with automated gates for tests, coverage on new code and analysers, cut change-failure rate from roughly 20% to under 10% over two quarters, while deployment frequency went from fortnightly to several times a week.

🔍 What the interviewer is checking

Checks whether the candidate can design a quality system for a team that balances rigour and flow, using automation and evidence.

Green flags

  • Distinguishes DoD from acceptance criteria
  • Short, verifiable list where done means in production and observable
  • Automates gates in CI and branch policies; keeps humans for judgement
  • Tailors by work type and evolves using metrics

Red flags

  • Long manual checklist
  • Done equals merged
  • No way to tell whether the DoD is helping

📚 Learn in depth

1. What the DoD is in Scrum

The Scrum Guide defines the Definition of Done as a formal description of the state of the increment when it meets the quality measures required for the product. If a backlog item doesn't meet it, it can't be released or even presented at the sprint review. Acceptance criteria are item-specific; the DoD applies to all items.

Acceptance criteria  ->  "Customer can request a partial refund"
Definition of done   ->  tested, reviewed, observable, deployed

2. Done should mean in production

Work that is merged but not deployed is inventory: it carries risk and gives no feedback. Ending done at production, often behind a feature flag, shortens feedback loops and surfaces integration problems while the author still has context. This aligns with continuous delivery and DORA metrics (deployment frequency, lead time, change-failure rate, time to restore).

3. Turning DoD items into gates

PR opened
   |
   v
CI: build (warnings as errors) -> tests -> coverage on new code
    -> dotnet format -> vulnerable packages -> secret scan
   |
   v
Branch policy: >= 1 approval, linked work item, all checks green
   |
   v
Merge -> deploy to test -> smoke tests -> deploy to prod (flag off)
   |
   v
Verify: dashboard + alert, flag on for cohort, rollback ready

Every automated gate removes a checklist item humans would otherwise forget or skip.

4. Quality attributes to include

  • Testing: unit plus integration tests (WebApplicationFactory, Testcontainers).
  • Security: analysers, secret scanning, dependency scanning; threat model for changes handling personal or payment data.
  • Privacy: personal information handled per the Privacy Act 1988 and APPs, not logged in plain text.
  • Performance: for hot paths, a performance budget (for example p95 under 200 ms for the order API) checked by a BenchmarkDotNet comparison or a short load test (k6, Azure Load Testing) in the pipeline for changes that touch them, plus production latency dashboards. Mature systems often gate releases on a load-test regression threshold.
  • Operability: structured logs, OpenTelemetry metrics and traces, an alert for new failure modes.
  • Documentation: OpenAPI spec, runbook, ADR when architectural.

5. Introducing it to a legacy codebase

A new DoD applied to old code fails every build. Apply it to new and changed code: SonarQube's new-code period for coverage and issues, analyser warnings baselined and ratcheted down, regression tests required for bug fixes. The legacy area improves as it is touched, which is also where the interest on debt is highest.

6. Keeping it alive

Review the DoD in a retro each quarter. Use evidence: escaped defects (what slipped through, and which DoD item would have caught it), change-failure rate, lead time. Add an item when a class of defect repeats; remove one when it never catches anything.

7. Cost of each item

Every item multiplies across every story. A 10-minute manual check on 40 stories a sprint is nearly seven hours. Automate it or justify it.

Try it yourself

  1. Write down your team's current DoD (or what people actually do) and mark each item automated or manual.
  2. Turn one manual item into a CI gate (for example, dotnet list package --vulnerable failing the build).
  3. List the last ten escaped defects and note which DoD item would have caught each.
  4. Add a BenchmarkDotNet comparison or a short k6 load test for one hot endpoint and set a regression threshold.
  5. Pull your DORA metrics for the last quarter from your pipeline history and propose one item to remove and one to add in the next retro.

💻 Code

The automated part of the definition of done as a GitHub Actions workflow, so every PR is checked the same way.

# .github/workflows/pr.yml
name: pr-checks
on: pull_request
jobs:
  done-gates:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '10.0.x'
      - run: dotnet restore
      - run: dotnet format --verify-no-changes --no-restore         # DoD 3: no style drift
      - run: dotnet build --no-restore -c Release -warnaserror       # DoD 1: analysers as errors
      - run: dotnet test --no-build -c Release --collect:"XPlat Code Coverage"   # DoD 2
      - name: Fail on vulnerable packages                             # DoD 3
        run: |
          dotnet list package --vulnerable --include-transitive | tee vuln.txt
          ! grep -q -i "has the following vulnerable packages" vuln.txt

The 'observable' item in code: a new feature ships with its metric and a structured log, so done can be verified in production.

namespace Orders.Application.Refunds;

using System.Diagnostics.Metrics;
using Microsoft.Extensions.Logging;

public sealed partial class RefundService(IMeterFactory meters, ILogger<RefundService> logger)
{
    private readonly Counter<long> _refunds =
        meters.Create("Orders.Refunds").CreateCounter<long>("orders.refunds.requested", unit: "{refund}");

    public Task<RefundResult> RequestAsync(RefundRequest request, CancellationToken ct)
    {
        _refunds.Add(1, new KeyValuePair<string, object?>("reason", request.Reason));
        LogRefundRequested(request.OrderId, request.Amount);   // no customer PII in logs
        // ... business logic
        return Task.FromResult(new RefundResult(Guid.NewGuid(), RefundStatus.Pending));
    }

    [LoggerMessage(Level = LogLevel.Information, Message = "Refund requested for order {OrderId}, amount {Amount}")]
    private partial void LogRefundRequested(Guid orderId, decimal amount);
}

public sealed record RefundRequest(Guid OrderId, decimal Amount, string Reason);
public sealed record RefundResult(Guid RefundId, RefundStatus Status);
public enum RefundStatus { Pending, Approved, Rejected }

⚠ Common mistakes

  • Mistake: A long manual checklist of 20+ items. Why it is wrong: Unless most of it is automated or built into the workflow, long lists get skimmed and become box-ticking, and every manual item costs time on every story. Instead: Aim for roughly 6–10 verifiable items as a default; if the context genuinely needs more (regulated payments, medical), automate them so the human list stays short.
  • Mistake: Done ends at 'merged' or 'code reviewed'. Why it is wrong: Integration, deployment and operational problems become someone else's job and appear late. Instead: Done means deployed to production (flag off is fine) and observable.
  • Mistake: Confusing the DoD with acceptance criteria. Why it is wrong: Quality standards get renegotiated per story. Instead: Acceptance criteria per item; DoD applies to every item.
  • Mistake: Manual checks for things a tool can verify. Why it is wrong: They cost time on every story and get skipped under pressure. Instead: Make them CI gates and branch policies.
  • Mistake: Global coverage targets. Why it is wrong: Teams game them with trivial tests, and legacy code makes the number meaningless. Instead: Gate on coverage of new code, plus review of test quality.
  • Mistake: Applying a new DoD retroactively to the whole legacy codebase. Why it is wrong: Thousands of existing warnings or untested classes block every PR and the team abandons the DoD. Instead: Apply gates to new and changed code (new-code coverage, analyser baselines) and ratchet over time.
  • Mistake: One DoD rigidly applied to spikes and infra work. Why it is wrong: It forces pointless work and people start ignoring the DoD. Instead: Tailor by work type while keeping the core.
  • Mistake: Never revisiting it. Why it is wrong: Items that never catch defects stay, while new failure classes go unaddressed. Instead: Review quarterly using escaped defects and DORA metrics.

🏛 Senior insight: trade-offs

The DoD is an architectural decision about where quality is enforced. Senior engineers push enforcement left and into automation, so quality is the default path, and keep human attention for judgement: design, security reasoning and whether the user need is met. They also treat the DoD as a living agreement that the team owns, not a policy handed down.

Option When it fits Cost When not to
CI gate Objective, tool-checkable item Pipeline minutes, setup once Judgement calls
Branch policy Approvals, linked work items Merge friction Solo hotfix with an agreed break-glass process
Review checklist item Needs human judgement Reviewer time Tool could check it
Per-work-type extension Spikes, infra, bugs Some complexity It weakens the core items

Measure whether it works: change-failure rate, escaped defects per sprint, lead time for changes. If quality improves but lead time doubles, the DoD needs more automation, not more items.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions analysers or warnings as errors as a DoD gate. Why: Checks they can introduce such a gate into a codebase that doesn't meet it yet.
    How to answer

    I wouldn't try to fix 5,000 warnings. I'd measure, stop new ones, then pay down by value.

    • Measure: a binary log grouped by diagnostic id and project; usually ten ids are 80% of the count.
    • Decide per rule with the team: enforce the ones that are real bugs (CS8602, CA2000, CA2100), auto-fix the style ones, and switch off the noise in .editorconfig, recorded in an ADR.
    • Stop the bleeding: rules already at zero become errors; a CI ratchet fails the build if the count rises above a committed baseline, which only moves down.
    • Pay down: mechanical dotnet format PRs with no behaviour change; risky fixes (nullability, disposal) area by area with tests, boy-scout style.

    Trade-off: the ratchet is slower than a clean-up sprint, but it never blocks delivery and the count can only go one way.

  2. When: Candidate mentions coverage on new code or a quality gate. Why: Checks they understand SonarQube's new-code focus and how to avoid metric gaming.
    How to answer

    SonarQube runs in CI: the dotnet-sonarscanner wraps your build (begin → dotnet build → dotnet test → end), collects Roslyn analyser results plus imported coverage, and the server stores issues over time.

    A quality gate is a set of pass/fail conditions. The default Sonar way gate looks only at new code: no new issues, every new security hotspot reviewed, at least 80% coverage on new lines, at most 3% duplication. The new code period (previous version, N days or a reference branch) is what makes legacy code adoptable: you don't fix the past, you stop making it worse.

    The Community Build only analyses the main branch; pull request decoration needs Developer Edition or above, or SonarQube Cloud.

    Trade-off: gates focus attention, but once a number becomes a target people game it (assert-free tests, bulk Won't fix), so keep few conditions and review how issues are resolved.

  3. When: Candidate mentions PR review as part of done. Why: Checks they know what makes a PR reviewable in the first place.
    How to answer

    A good pull request is one a reviewer can understand, verify and approve in one sitting.

    • Size: small and focused on one change, ideally under about 400 changed lines. Review quality drops sharply on large diffs, so split refactoring from behaviour change.
    • Description: explain why, not just what: the problem, the approach, how you tested it and any risk or rollout step. Link the work item.
    • Tests: include tests that prove the new behaviour, and make sure CI is green before you ask for review.
    • Self-review: read your own diff in the PR tool first and remove debug code, commented-out code and unrelated changes.

    The trade-off: splitting work into small PRs costs the author a little planning time, but it saves reviewers far more and gets the change merged sooner.

🛠 Real-world problems: how you handle them

High change-failure rate with done meaning 'merged'
Situation
A [size] team running a .NET order API on Azure App Service ([region]), releasing fortnightly. The DoD was 'code reviewed and merged'; testing and deployment happened later in a release branch.
Signals
About one in five releases needed a hotfix; bugs found days after merge when the author had moved on; long release nights; product owner losing confidence in sprint commitments.
Investigation
Pulled two quarters of release history to calculate change-failure rate and lead time; categorised escaped defects (missing integration tests, config drift, an unhandled null from a vulnerable package update); checked which current DoD items were actually verified.
Resolution
Rewrote the DoD with the team in a retro: eight items ending at 'deployed to production and verified', with build, tests, new-code coverage, analysers, `dotnet format` and vulnerable-package checks as CI gates, branch policies for approvals, and feature flags so incomplete work could ship dark. Moved to deploying from main several times a week.
Prevention
Quarterly DoD review using escaped defects and DORA metrics; regression test required for every bug fix; dashboard showing change-failure rate and lead time.

How to tell it (STAR)

**S:** At [company], our DoD ended at 'merged', we released fortnightly, and about one release in five needed a hotfix. **T:** I wanted to raise quality without making delivery slower. **A:** I pulled release history and categorised escaped defects, then ran a retro where the team rewrote the DoD: eight items, ending at deployed and verified in production. We automated tests, coverage on new code, analysers and package scanning as CI gates, used branch policies for review, and shipped incomplete work behind flags. **R:** Over [two quarters] change-failure rate fell from about [20%] to [under 10%], and we went from fortnightly to [several deployments a week].

↩ Usually asked after

More in Engineering Practice

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me