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

📚 Interview question

What is Domain-Driven Design? Explain the difference between strategic and tactical design, what a ubiquitous language is, and how you decide whether DDD is worth the effort on a project.

Covers what DDD is, strategic versus tactical design, the ubiquitous language, and the criteria for when DDD pays off and when it is ceremony.

Junior Theory Beginner architecture bounded-context domain-driven-design strategic-design tactical-design ubiquitous-language

🎯 Key points

  • DDD = model the software on the business domain, built with domain experts (Eric Evans, 2003)
  • Strategic design: subdomains (core, supporting, generic), bounded contexts, context maps
  • Tactical design: entities, value objects, aggregates, domain events, repositories, domain services
  • Ubiquitous language: one shared vocabulary in conversations, code, tests and the UI, per bounded context
  • Scale the effort to the complexity: light strategic thinking on most multi-area systems, tactical patterns only in complex core domains
  • Continuous collaboration with domain experts and stakeholders (event storming, example mapping each sprint), not a one-off workshop
  • Legacy systems adopt DDD incrementally: refactor one core area at a time behind an anti-corruption layer
  • Not worth it for CRUD, reporting or generic subdomains (buy or use a simple transaction script)

⏱ 30-second answer

Domain-Driven Design is an approach where the software model mirrors the business domain and is built in close collaboration with domain experts. It has two halves. Strategic design splits a large problem into subdomains (core, supporting, generic) and bounded contexts, each with its own model, and maps how they relate. Tactical design gives building blocks for the model inside one context: entities, value objects, aggregates, domain events, repositories and domain services. The glue is the ubiquitous language: the same words in meetings, code, tests and the UI.

DDD is worth it for a complex, changing core domain that gives the business its edge. For CRUD screens or generic problems (auth, invoicing PDFs) the tactical patterns are ceremony: use strategic thinking everywhere, tactical patterns only where the rules are hard.

🗣 Full answer (senior)

How I would answer this in an interview

"Domain-Driven Design is a way of building software where the code is a model of the business, and that model is shaped together with the people who know the business: the domain experts. Eric Evans described it in 2003, and it has two halves. Strategic design is about the big picture: which parts of the business are the core, the bit that makes money or sets us apart, which are supporting, and which are generic and could be bought. It splits the system into bounded contexts, each with its own model and its own language, and draws a context map of how they talk. Tactical design is the toolbox inside one context: entities with identity, value objects compared by value, aggregates that protect invariants, domain events, repositories and domain services.

The thread through all of it is the ubiquitous language. If the claims team says a claim is 'lodged' and then 'assessed', the code has Claim.Lodge() and Claim.Assess(), not UpdateStatus(3). Tests read in the same words, so a domain expert can look at a test name and say 'yes, that is the rule' or 'no, we never do that'. The language is only ubiquitous inside one bounded context: 'Customer' in Sales and 'Customer' in Billing can legitimately mean different things.

The mistake I see is teams adopting the tactical patterns, aggregates and repositories everywhere, on a CRUD app, and calling it DDD, while never talking to a domain expert. That gives you all the cost and none of the benefit. I use strategic design on almost every system, because finding boundaries is always useful, and the tactical patterns only in the core domain where the rules are genuinely complex. DDD is a tool for complexity, not a default."


Strategic vs tactical design

Strategic design Tactical design
Question it answers Where are the boundaries? What matters most? How do I model the rules inside one boundary?
Building blocks Subdomains, bounded contexts, context maps, ubiquitous language Entities, value objects, aggregates, domain events, repositories, domain services, factories
Who is involved Domain experts, architects, product owners, team leads Developers with domain experts
Useful for Nearly every non-trivial system Complex core domains only

The three kinds of subdomain

Subdomain Example (an Australian insurer) Investment
Core Pricing and claims assessment rules Best developers, rich model, tactical DDD
Supporting Broker portal, document generation Simpler design, CRUD is often fine
Generic Identity (Microsoft Entra ID), payments, email Buy or use SaaS; do not build

When DDD is worth it

Worth it Not worth it
Many business rules that interact and change often Forms over data, mostly CRUD
Domain experts available and willing to collaborate No access to experts; requirements arrive as tickets only
Long-lived system that will evolve for years Short-lived tool, prototype, migration script
Several teams that need clear boundaries One small team, one simple app

Production example

On a [policy administration] system, renaming the code to match the underwriters' language (Endorse, Lapse, Reinstate instead of UpdatePolicy) and moving the rules into the Policy model cut the defects raised in UAT for rule changes from [about 12 per release to 3]. The same team kept the broker contact screens as plain CRUD with EF Core, because there were no rules worth modelling there.

🔍 What the interviewer is checking

Checks that the candidate understands DDD as a way to handle domain complexity, not a set of folder names, and can judge when it is worth it.

Green flags

  • Separates strategic from tactical design and says strategic matters more
  • Explains the ubiquitous language with a concrete code example
  • Knows core, supporting and generic subdomains
  • Says plainly when not to use DDD

Red flags

  • Defines DDD as "Domain, Application, Infrastructure folders"
  • Never mentions domain experts
  • Wants aggregates and repositories for a CRUD app

📚 Learn in depth

1. Why DDD exists

Most software fails not because of technology but because the code drifts away from how the business actually works. Every translation layer (business analyst → spec → developer → code) loses meaning. DDD removes translations: experts and developers build one model, expressed directly in code.

Without DDD                      With DDD
-----------                      --------
Expert ──► BA ──► Spec ──► Dev   Expert ◄──► Dev
  ("lodge a claim")                    │
                 code: Status = 3      code: claim.Lodge()

2. The ubiquitous language

  • It is a shared vocabulary for one bounded context, used in speech, code, tests, API names and the UI.
  • When the language changes, the code changes. If experts start saying "withdraw" instead of "cancel", rename the method.
  • It exposes hidden concepts: if experts keep saying "excess" and the code has decimal amount2, a value object is missing.
  • A glossary in the repo (docs/glossary.md) per bounded context keeps it honest.

3. Strategic design: finding the boundaries

+---------------------- Insurance company ----------------------+
|                                                               |
|  +-----------+    +-----------+    +-----------+              |
|  |  Pricing  |    |  Claims   |    |  Billing  |              |
|  |  (core)   |    |  (core)   |    |(supporting)|             |
|  +-----+-----+    +-----+-----+    +-----+-----+              |
|        |                |                |                    |
|        +------ events ---+---- events -----+                  |
|                                                               |
|  Identity (generic: Entra ID)   Payments (generic: Stripe)    |
+---------------------------------------------------------------+

Each box is a bounded context: inside it a word has exactly one meaning. The lines between them form the context map (partnership, customer-supplier, anti-corruption layer and so on).

4. Tactical design: the building blocks

Block One-line definition
Entity Has identity that lasts while its attributes change (Order #123)
Value object Defined only by its values, immutable (Money, Address)
Aggregate A cluster of objects changed together to keep invariants; one root
Domain event Something that happened that experts care about (ClaimLodged)
Repository Loads and saves whole aggregates
Domain service Domain logic that does not belong to one entity
Application service Orchestrates a use case: load, call the domain, save

5. How it maps to a .NET solution

src/
  Claims.Domain/          entities, value objects, events (no EF Core)
  Claims.Application/     use cases (commands and handlers)
  Claims.Infrastructure/  EF Core DbContext, repositories, messaging
  Claims.Api/             ASP.NET Core endpoints

The domain project has no dependency on EF Core or ASP.NET Core, so the rules can be tested in milliseconds with plain xUnit tests.

6. Costs

  • Time with domain experts (workshops, event storming).
  • More types: value objects, events, factories.
  • Mapping between rich domain objects and persistence (EF Core helps with private setters, backing fields and complex types).

Try it yourself

  1. Take a feature you have built recently and list ten nouns and verbs the business uses for it. How many appear in your code?
  2. Classify the parts of your current system as core, supporting or generic. Which generic parts did you build that you could have bought?
  3. Rename one UpdateStatus style method to an intention-revealing name such as Approve() and write a test named in business language.
  4. Write a one-page glossary for one area and ask a domain expert to correct it.

💻 Code

The ubiquitous language in code: an intention-revealing model instead of a status setter.

// Before: technical language; the rule lives somewhere else (or nowhere).
public class ClaimRecord
{
    public int Id { get; set; }
    public int Status { get; set; }   // 1 = draft, 2 = lodged, 3 = assessed?
    public decimal Amount { get; set; }
}
// After: the code speaks the claims team's language and enforces the rule.
namespace Claims.Domain;

public enum ClaimStatus { Draft, Lodged, Assessed }

public sealed class Claim
{
    public Guid Id { get; } = Guid.CreateVersion7();
    public ClaimStatus Status { get; private set; } = ClaimStatus.Draft;
    public DateTimeOffset? LodgedAt { get; private set; }

    // "A claim can only be lodged once, and only from draft."
    public void Lodge(TimeProvider clock)
    {
        if (Status != ClaimStatus.Draft)
            throw new InvalidOperationException($"Claim {Id} is already {Status}.");

        Status = ClaimStatus.Lodged;
        LodgedAt = clock.GetUtcNow();
    }
}
// A test a domain expert can read.
public class ClaimTests
{
    [Fact]
    public void A_lodged_claim_cannot_be_lodged_again()
    {
        var claim = new Claim();
        claim.Lodge(TimeProvider.System);

        Assert.Throws<InvalidOperationException>(() => claim.Lodge(TimeProvider.System));
    }
}

⚠ Common mistakes

  • Mistake: Treating DDD as "use aggregates and repositories". Why it is wrong: the tactical patterns are the least important part; without domain experts and boundaries you only add layers. Instead: start with strategic design and the language, then use tactical patterns where the rules are complex.
  • Mistake: Applying tactical DDD to every part of the system. Why it is wrong: CRUD and generic subdomains gain nothing from aggregates and pay the cost. Instead: classify subdomains and keep supporting ones simple.
  • Mistake: One enterprise-wide model of "Customer". Why it is wrong: every department means something different, so the model becomes a bloated compromise. Instead: one model per bounded context.
  • Mistake: Inventing technical names (Manager, Processor, Status = 3). Why it is wrong: experts cannot read or check the code. Instead: use the experts' verbs and nouns.
  • Mistake: Building generic subdomains in-house. Why it is wrong: it spends your best people on problems others have solved. Instead: buy or use SaaS for identity, payments and email.
  • Mistake: Doing DDD without domain experts, or with one kick-off workshop and nothing after. Why it is wrong: the model reflects developers' guesses and drifts from the business as it changes. Instead: make expert collaboration part of the Agile cadence: event storming at the start, example mapping in backlog refinement, experts reviewing test names.
  • Mistake: A big-bang rewrite of a legacy system "to do DDD properly". Why it is wrong: it stops delivery for months and usually recreates the old model with new names. Instead: refactor incrementally: pick one core area, put an anti-corruption layer in front of the legacy model, move rules into a rich model behind tests, and repeat.
  • Mistake: Ignoring the language in simple areas because "it is only CRUD". Why it is wrong: mismatched names still cost time and create technical debt when the area later grows rules. Instead: keep the ubiquitous language even where you skip tactical patterns, so the area can evolve cheaply.

🏛 Senior insight: trade-offs

The senior answer is that DDD is an investment decision. Strategic design (subdomains, bounded contexts, language) is cheap and pays off almost everywhere because it tells you where to put boundaries and where to spend your best people. Tactical design is expensive and only pays off in a complex core domain. I can say which parts of a system deserve it and which should stay as CRUD or be bought.

Approach When it fits Cost When not to
Full DDD (strategic + tactical) Complex, changing core domain with expert access High: workshops, more types, mapping CRUD, short-lived apps
Strategic DDD only Any multi-team or multi-area system Low Tiny single-purpose tools
Transaction script / CRUD Simple rules, forms over data Lowest Rules that interact and change often

I measure whether it is working by how often rule changes cause defects, and whether experts can review tests written in their language.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions domain services or application services. Why: Checks they can place logic correctly between application and domain services.
    How to answer

    These are three layers of responsibility:

    • An application service (Fowler's service layer) runs one use case. It loads aggregates through repositories, calls domain logic, commits the unit of work and publishes events. It handles transactions, authorisation and mapping, but holds no business rules.
    • A domain service holds stateless business logic that doesn't belong to one entity, often spanning aggregates (a funds transfer, a pricing policy). It's named in domain language and knows nothing about HTTP or EF Core.
    • Entities and value objects own their own invariants (order.Submit()), and they come first.

    When everything goes into a fat OrderService, entities become property bags: the anaemic domain model. Controllers should only translate HTTP. The trade-off is richer models and clear boundaries against more types and more thought about where each rule lives.

  2. When: Candidate says the ubiquitous language applies within a bounded context. Why: Checks they understand the core strategic building block.
    How to answer

    A bounded context is the boundary within which one model and one language apply consistently. You find its edges where the language changes (the same word means different things), where different experts or stakeholders own the rules, and where parts of the domain change for different reasons and at different rates (tax rules yearly, catalogue daily), because those parts need models that can evolve separately. Each context usually maps to one team and one module or service. Contexts still have to work together, so you draw a context map of how they integrate (customer-supplier, anti-corruption layer, published events) and keep each context's data private behind those integrations.

  3. When: Candidate talks about putting behaviour on domain objects. Why: Checks they connect rich domain models to Tell, Don't Ask.
    How to answer

    Tell, Don't Ask means you tell an object what you want done, and the object decides how, using its own data. Instead of a service doing if (order.Status == Pending && !order.IsPaid) order.Status = Cancelled;, you call order.Cancel(), and the order enforces the rule. That keeps invariants in one place, removes duplicated checks across services and moves you from an anaemic model towards a rich one. It applies to behaviour; for reading data to display or report, querying is exactly right.

↩ Usually asked after

More in Domain-Driven Design

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me