Plenty of developers say “aggregate root” or “bounded context” in design meetings while being a little vague about what they mean. The words from Eric Evans’ Domain-Driven Design (the blue book, published in 2003) spread much further than the ideas behind them.[1] You can have folders named Aggregates, ValueObjects, and Repositories and still have a model that nobody in the business would recognize.
The usual cause is adopting the tactical patterns (entities, value objects, repositories) and leaving the strategic design (language, boundaries, and where to spend effort) on the shelf. The tactical patterns look like code, so they’re easy to pick up. The strategic ones require talking to people, and they decide whether the tactical ones are drawn in the right places. I’ll give bounded contexts and aggregates the most attention, using C# and a fictional online retailer.
Bounded Contexts
A bounded context is an explicit boundary within which one domain model, and the language that goes with it, applies consistently.
Inside the boundary, a term has one meaning and the rules attached to it don’t contradict each other. Outside it, all bets are off. The same word may mean something else, and that’s fine as long as you know where the line is and translate when you cross it.
Some differences are obvious. In a store, an order is a request to buy something. In the army, it’s an instruction an officer gives a soldier. Nobody would try to serve both with one Order class. The trouble comes from meanings close enough to look identical.
Suppose a customer buys a desk and a lamp in one checkout. The lamp is in stock in Newark, and the desk is in a warehouse in Reno. Ask three parts of the business about “the order”:
- Ordering sees one order. It’s the customer’s request to buy two items at an agreed price, and it’s placed as soon as checkout succeeds.
- Fulfillment sees two orders, one for each warehouse to pick, pack, and ship. The lamp’s order can be finished while the desk’s hasn’t started.
- Billing sees something to collect money for. It might charge as each box leaves, and it cares about payments and refunds, not shelves.
Now ask whether the order is complete. Ordering might say yes because the customer has checked out, Fulfillment says half of it is, and Billing says no until the second charge clears. All three are right. A single Order class would need one Status property to answer three different questions. Separate models let each context have its own states and rules, linked by an order ID.
The alternative, one model for the whole company, sounds efficient and ages badly. Every department’s needs pile onto the same classes until nobody can change anything without asking everybody.
One Word, Four Meanings
Take “product.”
| Context | What “product” means there | Data it cares about | A rule it owns |
|---|---|---|---|
| Catalog | Something a customer can find and read about | Name, description, images, category | A listing can’t go live without a description |
| Inventory | Units we physically hold and can promise | SKU, location, quantity on hand | We can’t reserve more than we have |
| Pricing | Something with a price at a point in time | Price lists, currency, effective dates | Two prices can’t be active for the same market at once |
| Shipping | A thing that has to fit in a box | Weight, dimensions, hazard class | Some hazardous items can’t go by air |
The tempting design is one Product class with every column from that table, most of them irrelevant (and often null) for any given use. Someone adds IsActive, and four teams read it four ways.
With bounded contexts, each gets its own model, containing only what its rules need. Catalog has a Product, while Inventory talks about stock items. They share an identifier, such as the SKU, not a class. If the product name shows up in more than one context, that’s a copy with a known owner (Catalog), kept current by a message or a query. It’s a far smaller problem than one class serving four masters.
Finding the Boundaries
Ubiquitous language is the shared vocabulary that developers and domain experts use, within one context, in conversation, documents, and code alike.
Teams tend to treat this as a naming convention, but it’s also the best boundary detector you have. “Ubiquitous” means everywhere inside a context, not one dictionary for the enterprise. When you try to define a term and the experts start saying “well, not for us,” you’ve probably found an edge. Listen for these:
- The same word with different meanings. “Customer” to Sales might be a prospect, and to Billing it’s whoever pays the invoice.
- Different words for the same thing. If the warehouse says “pick” and the storefront says “fulfill,” check whether they mean the same step. They may be two models of one physical event.
- Different experts. If a question about pricing and a question about packing go to different people, one model is unlikely to serve both well.
- Handoffs. Where work moves between departments and someone re-keys or reinterprets it, there is usually a translation your software should make explicit.
None of these is proof. Boundaries are design decisions, and you will move some of them as you learn.
What a Bounded Context Is Not
- Not a microservice. A context can be one module in a monolith, and often should start that way. It can also be implemented by more than one deployable. The context is about where a model is valid; a service is about how software is deployed. Evans has called equating the two an oversimplification.[2] Several services designed and changed together can form one context. The trouble starts when you treat them as independent and they still have to change in lockstep.
- Not a module or namespace. Those are fine tools for enforcing a boundary, but creating a
Pricingfolder does nothing if its classes referenceCatalog.Productdirectly. - Not a team. One team can own several contexts. Two teams sharing one context is possible too, though it takes constant coordination to keep the model from splitting.
- Not a subdomain. A subdomain is an area of the business, such as billing or shipping, and it exists whether or not you write any software. A bounded context is a line you draw around a model in that software. One context per subdomain is a good aim, but the two often don’t match. A legacy system that handles both billing and shipping with a single
Ordermodel is one context spanning two subdomains. During a rewrite, an old and a new billing system, each with its own model, can be two contexts inside one subdomain.[2]
Context Maps and Anticorruption Layers
A context map is an honest picture of which bounded contexts exist and how each pair that interacts is related, technically and organizationally.
The organizational part is what gets dropped. Boxes and arrows showing API calls don’t say who gets to change the contract. Here are some of the relationships Evans describes:
- Customer/supplier. The downstream team’s needs are part of the upstream team’s planning.
- Conformist. The downstream team adopts the upstream model as it is, usually because it has no say. That can be a reasonable choice when the upstream model is good enough.
- Anticorruption layer. The downstream team translates the upstream model into its own.
- Shared kernel. Two contexts share a small piece of model and code, and neither changes it without the other.
- Separate ways. The integration isn’t worth its cost, so you don’t build it.
An anticorruption layer is translation code that lets your model use another system without adopting that system’s concepts.
Suppose Inventory reads from an old warehouse system. It counts full cases, tracks held units separately, lets counts drift below zero, and packs meaning into one-letter status codes. Inventory only wants to know how many units it can sell. The translator is the only place that knows how to get from one to the other:
// The legacy system's shape. Nothing outside this layer should see it.
public sealed record WmsStockRow(
string ItemCode,
int CasesOnHand, // can be negative until the next stock count
int UnitsPerCase,
int HeldUnits, // set aside, but still included in the case count
string StatusCode);
// What Inventory cares about, in its own terms.
public sealed record StockSnapshot(Sku Sku, Quantity Sellable);
public static class WmsTranslator
{
public static StockSnapshot Translate(WmsStockRow row)
{
if (row.UnitsPerCase <= 0)
throw new InvalidDataException($"Bad case size for '{row.ItemCode}'.");
var physicalUnits = checked(Math.Max(row.CasesOnHand, 0) * row.UnitsPerCase);
var unheldUnits = Math.Max(physicalUnits - row.HeldUnits, 0);
var sellableUnits = row.StatusCode switch
{
"A" => unheldUnits, // active
"D" => unheldUnits, // discontinued, but we sell what's left
"Q" => 0, // quarantined
_ => throw new NotSupportedException($"Unknown WMS status '{row.StatusCode}'.")
};
return new StockSnapshot(new Sku(row.ItemCode), new Quantity(sellableUnits));
}
}
An adapter that copies StatusCode into a property on your domain class isn’t an anticorruption layer. The foreign concept got in; it just has a nicer name. The layer also costs something to write and maintain, so use it where the other model would distort yours.
Core Domain: Where DDD Pays Off
The core domain is the part of your domain model that sets the organization apart and therefore deserves your best design effort.
Evans separates it from generic subdomains, which are necessary but not special. Later DDD writing, including Vaughn Vernon’s, commonly adds supporting subdomains as a third category: specific to your business, but not what makes it competitive.[3]
| Subdomain type | Retailer example | Reasonable approach |
|---|---|---|
| Core | Promising delivery dates from scattered stock | Careful modeling, experienced people, frequent expert contact |
| Supporting | Managing supplier contact records | Simple code, plain CRUD is often enough |
| Generic | Authentication, general ledger, sending email | Buy it or use an established library |
Your table will differ. Pricing is core for one retailer and a spreadsheet import for another.
Teams often skip deciding which part is core, and it’s expensive. They wrap a settings screen in aggregates and repositories, then run out of patience before reaching the part of the system where the rules are hard. If a feature validates input and writes a row, write that code and move on. DDD earns its cost where the rules are intricate, change often, and matter to the business. I made a related argument about matching structure to complexity in In Defense of the Repository.
Entities and Value Objects
An entity is an object defined by a continuous identity that persists while its attributes change.
A value object is an immutable object defined entirely by its attributes, so two with equal values are interchangeable.
A stock item is an entity. Its quantity changes all day and it’s still the same stock item. A quantity of five is a value. Nobody cares which five.
Prefer value objects where identity doesn’t matter. They can’t be changed behind your back, they’re easy to test, and they give rules a home. Without them, those rules get repeated wherever an int or string is passed around.
public sealed record Sku
{
public Sku(string value)
{
ArgumentException.ThrowIfNullOrWhiteSpace(value);
Value = value.Trim().ToUpperInvariant();
}
public string Value { get; }
}
public readonly record struct Quantity
{
public Quantity(int value)
{
ArgumentOutOfRangeException.ThrowIfNegative(value);
Value = value;
}
public int Value { get; }
public static Quantity operator +(Quantity a, Quantity b) => new(checked(a.Value + b.Value));
public static Quantity operator -(Quantity a, Quantity b) => new(a.Value - b.Value);
public static bool operator >(Quantity a, Quantity b) => a.Value > b.Value;
public static bool operator <(Quantity a, Quantity b) => a.Value < b.Value;
}
These use get-only properties on purpose. A positional record gives you init accessors, so a with expression could produce a new value that skips the constructor’s checks.
Record or Value Object Base Class?
I start with a record. The compiler writes equality and hashing for me. The catch is that some members, collections especially, compare by their own equality, so two records holding separate lists with identical items are not equal. For one unusual type, override Equals(T) and GetHashCode. A base class earns its place when many types need rules that records don’t give you, and since a record can’t inherit from an ordinary class, you’re choosing one or the other.
For a single primitive with rules, such as Quantity, a readonly record struct is a good fit. It gets generated equality and doesn’t need its own heap object. The condition is that default must be a valid value, because it skips your constructor. Zero is a fine quantity, while an empty SKU is not, so Sku stays a class. A struct also can’t inherit from ValueObject.
The next two examples use ShippingRestriction, which records a hazardous item’s hazard class and the transport modes it’s banned from. If a record holds a collection, don’t rely on the generated equality. Copy the collection in the constructor and compare its items:
public bool Equals(ShippingRestriction? other) =>
other is not null
&& HazardClass == other.HazardClass
&& BannedModes.SequenceEqual(other.BannedModes);
public override int GetHashCode()
{
var hash = new HashCode();
hash.Add(HazardClass);
foreach (var mode in BannedModes)
hash.Add(mode);
return hash.ToHashCode();
}
These are the two members you’d add to a record version of ShippingRestriction, with the same constructor and properties as the class shown below.
Microsoft’s guide shows a base class where each type lists its equality components,[4] and Vladimir Khorikov prefers that style to records for the control it gives.[5] I have also used a base class that finds the properties through reflection and caches them, so new properties join equality automatically. Here is a small version written for this post:
using System.Collections;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
[AttributeUsage(AttributeTargets.Property)]
public sealed class NotPartOfValueAttribute : Attribute;
// Tells the trimmer to keep public properties on this class and its subclasses
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)]
public abstract class ValueObject : IEquatable<ValueObject>
{
private static readonly ConcurrentDictionary<Type, PropertyInfo[]> Cache = new();
private static readonly object Start = new(), End = new();
public bool Equals(ValueObject? other) =>
other is not null
&& other.GetType() == GetType()
&& Components().SequenceEqual(other.Components());
public override bool Equals(object? obj) => Equals(obj as ValueObject);
public override int GetHashCode()
{
var hash = new HashCode();
hash.Add(GetType());
foreach (var component in Components())
hash.Add(component);
return hash.ToHashCode();
}
public static bool operator ==(ValueObject? a, ValueObject? b) => Equals(a, b);
public static bool operator !=(ValueObject? a, ValueObject? b) => !Equals(a, b);
private IEnumerable<object?> Components() =>
Properties().SelectMany(p => Flatten(p.GetValue(this)));
// Collections count item by item, in order. The markers keep nesting distinct.
private static IEnumerable<object?> Flatten(object? value) =>
value is IEnumerable items and not string
? items.Cast<object?>().SelectMany(Flatten).Prepend(Start).Append(End)
: [value];
private PropertyInfo[] Properties()
{
if (Cache.TryGetValue(GetType(), out var cached))
return cached;
// Call GetProperties directly on GetType() so the trimmer can follow it
var found = GetType()
.GetProperties(BindingFlags.Instance | BindingFlags.Public)
.Where(p => p.GetIndexParameters().Length == 0
&& !p.IsDefined(typeof(NotPartOfValueAttribute)))
.ToArray();
return Cache.GetOrAdd(GetType(), found);
}
}
A value object that uses it only has to validate and expose its properties:
public sealed class ShippingRestriction : ValueObject
{
public ShippingRestriction(string hazardClass, params string[] bannedModes)
{
ArgumentException.ThrowIfNullOrWhiteSpace(hazardClass);
HazardClass = hazardClass;
// Copy and sort, so callers can't mutate it and input order doesn't matter
BannedModes = Array.AsReadOnly(
bannedModes.Distinct().Order(StringComparer.Ordinal).ToArray());
}
public string HazardClass { get; }
public IReadOnlyList<string> BannedModes { get; }
[NotPartOfValue] // derived from BannedModes
public bool CanShipByAir => !BannedModes.Contains("Air");
}
Two restrictions with the same hazard class and banned modes are equal, however the modes were passed in. Mark computed properties with [NotPartOfValue]. Otherwise equality evaluates them, and one that returns a new instance of its own type can recurse until the stack overflows. Sets and dictionaries don’t promise an order, so the base class can’t reliably compare properties of those types as written. It also allocates on every comparison, which a simple record avoids.
The DynamicallyAccessedMembers attribute is easy to leave out because everything works without it in an ordinary build. When I removed it and published a trimmed test build, values that differed compared as equal, because the trimmer had removed properties that nothing else read. It couldn’t tell which properties the reflection call needed. The warning is IL2075 when you call GetType().GetProperties() directly, or IL2070 when the Type arrives as a parameter, such as in a cache’s factory lambda. The attribute tells it what to keep, and the direct call lets it verify that. Test your own trimmed build, and see Microsoft’s trimming guidance for other cases.[6]
Aggregates
An aggregate is a cluster of objects treated as one consistency boundary, which protects one or more invariants and is changed only through a single root entity.
An invariant is a rule that must be true every time a transaction commits. “Reserved stock never exceeds stock on hand” is one. The aggregate exists to make that rule impossible to break. “These objects are related” is not a reason to make an aggregate. Nearly everything in a business is related to everything else.
A Root That Enforces Its Rule
In the Inventory context, StockItem is the root. Reservations live inside it because the rule can’t be checked without them.
public readonly record struct ReservationId(Guid Value);
public sealed record Reservation(ReservationId Id, Quantity Quantity);
public interface IDomainEvent;
public sealed record StockReserved(Sku Sku, ReservationId ReservationId, Quantity Quantity)
: IDomainEvent;
public class DomainException(string message) : Exception(message);
public sealed class InsufficientStockException(Sku sku)
: DomainException($"Not enough available stock for {sku.Value}.");
// The aggregate root. Invariant: Reserved never exceeds OnHand.
public sealed class StockItem(Sku sku, Quantity onHand)
{
private readonly List<Reservation> _reservations = [];
private readonly List<IDomainEvent> _events = [];
public Sku Sku { get; } = sku;
public Quantity OnHand { get; private set; } = onHand;
public int Version { get; private set; } // optimistic concurrency token
public Quantity Reserved =>
_reservations.Aggregate(new Quantity(0), (sum, r) => sum + r.Quantity);
public Quantity Available => OnHand - Reserved;
public IReadOnlyList<Reservation> Reservations => _reservations.AsReadOnly();
public IReadOnlyList<IDomainEvent> Events => _events.AsReadOnly();
public void Reserve(ReservationId id, Quantity quantity)
{
ArgumentOutOfRangeException.ThrowIfZero(quantity.Value);
Reservation? existing = _reservations.Find(r => r.Id == id);
if (existing is not null)
{
if (existing.Quantity != quantity)
throw new DomainException("That reservation exists with a different quantity.");
return; // the same request again changes nothing
}
if (quantity > Available)
throw new InsufficientStockException(Sku);
_reservations.Add(new Reservation(id, quantity));
_events.Add(new StockReserved(Sku, id, quantity));
Version++;
}
public void Release(ReservationId id)
{
if (_reservations.RemoveAll(r => r.Id == id) > 0)
Version++;
}
public void Dispatch(ReservationId id)
{
Reservation reservation = _reservations.Find(r => r.Id == id)
?? throw new DomainException("No open reservation to dispatch.");
_reservations.Remove(reservation);
OnHand -= reservation.Quantity;
Version++;
}
public void WriteOff(Quantity damaged)
{
if (damaged > Available)
throw new DomainException("Release reservations before writing off that much stock.");
OnHand -= damaged;
Version++;
}
public void ClearEvents() => _events.Clear();
}
Outside code can read the reservations but can’t add one. AsReadOnly() matters, because returning the List<T> typed as IReadOnlyList<T> lets a caller cast it back and mutate it. OnHand has a private setter. Every path that changes state goes through a method that keeps the rule.
In memory, that’s enough. With a database, two requests can each load the same item, each see five available, and each reserve five. Version closes that gap, provided your persistence layer treats it as a concurrency token (IsConcurrencyToken() in EF Core), so the second save fails and has to retry against fresh data. It lives on the root and changes with every modification, including changes that only touch child rows. An ORM also needs mapping configuration for these types, which I’ve left out.
The Rules of Thumb
Evans’ book establishes the root as the only member that outside objects may hold on to, and requires invariants inside the boundary to hold when each transaction completes. Vaughn Vernon’s 2011 essays, “Effective Aggregate Design,” sharpened this into guidance that many of us now repeat without credit, particularly keeping aggregates small and referencing other aggregates by identity.[7]
- Go through the root. Don’t hand out mutable internals, and don’t update a child table directly. A
DbSet<Reservation>that application code can write to is a hole in the wall. - Treat the aggregate as the transaction boundary. The default is to modify one aggregate instance per transaction.
- Reference other aggregates by ID. An order line holds a
Sku, not aStockItem. If you can’t navigate to it, you’re much less likely to modify it by accident. - Keep them small. Include what the invariant needs and little else.
StockItemholds open reservations only. Dispatched ones leave, and their history belongs elsewhere. - Use eventual consistency across aggregates. If a rule spanning two of them can lag by seconds or hours, let it. Evans’ book already allows for this; Vernon made it much more prominent.
Vernon also discusses reasons to break these defaults. To choose between immediate and eventual consistency, he passes along a test that came out of a discussion with Evans. Is making the data consistent the job of the user performing this action? If so, lean transactional. If it’s another user’s job, or the system’s, eventual consistency is probably acceptable. Confirm it with a domain expert, because “how stale can this be?” is a business question.
When the Boundary Is Wrong
The classic mistake is modeling aggregates after the object graph. A customer has orders, orders have lines, lines have products, so Customer becomes the root of everything. It mirrors the foreign keys and protects nothing in particular. Symptoms worth looking for:
- Contention. Unrelated users get concurrency conflicts or lock waits because their changes land on the same root. Changing a delivery note shouldn’t collide with placing a new order.
- Slow loads. A one-field change pulls in thousands of child rows, or lazy loading fires query after query.
- Transactions that save several aggregates. If this is routine, either the boundary is wrong or you’re demanding immediate consistency the business doesn’t need.
- Collections that grow forever. Order history is a query. It rarely needs to be part of a consistency boundary.
- No invariant you can name. If you can’t finish the sentence “this aggregate guarantees that…”, ask why it’s an aggregate. A single entity with no children can be a perfectly good one, but a large cluster with no rule is not.
A large aggregate is occasionally right, when a rule really does span all of it. A very popular stock item can also be a hotspot despite a correct, small boundary. Then you need to ask whether the business can tolerate occasional overselling and a way to compensate for it.
Domain Events
A domain event is a record of something that happened in the domain that other parts of the system may need to react to.
Domain events aren’t one of the building blocks in the 2003 book. Evans’ later DDD Reference lists them as a term introduced since then.[1] They’re now the usual way to carry a change from one aggregate to the next. Name them in the past tense and in the domain’s words, like StockReserved, not StockItemRowUpdated.
Say the Ordering context announces that a line was placed. Inventory reacts in its own transaction. A message that crosses contexts like this is often called an integration event, and it’s a published contract, so it carries primitives instead of either model’s types.
public interface IStockItemRepository
{
Task<StockItem?> FindAsync(Sku sku, CancellationToken cancellationToken);
void Add(StockItem item);
}
public interface IUnitOfWork
{
Task SaveChangesAsync(CancellationToken cancellationToken);
}
public interface IOutbox
{
void Add(object message); // stored in the same transaction as the aggregate
}
public sealed record OrderLinePlaced(Guid OrderId, Guid LineId, string Sku, int Quantity);
public sealed record StockShortfall(Guid OrderId, Guid LineId);
public sealed class ReserveStockWhenOrderLinePlaced(
IStockItemRepository stockItems, IOutbox outbox, IUnitOfWork unitOfWork)
{
public async Task HandleAsync(OrderLinePlaced message, CancellationToken cancellationToken)
{
var sku = new Sku(message.Sku);
StockItem item = await stockItems.FindAsync(sku, cancellationToken)
?? throw new DomainException($"No stock item for {sku.Value}.");
try
{
item.Reserve(new ReservationId(message.LineId), new Quantity(message.Quantity));
}
catch (InsufficientStockException)
{
outbox.Add(new StockShortfall(message.OrderId, message.LineId));
}
await unitOfWork.SaveChangesAsync(cancellationToken);
}
}
A shortfall isn’t a rollback of the order, which has already committed. It’s a business event that needs a business answer, such as a backorder or a refund.
Eventual consistency is work you’re signing up for. Messages get redelivered, so handlers must tolerate repeats. Using the line ID as the reservation ID covers that while the reservation is open, but a duplicate arriving after dispatch would reserve again, so you’d still want a record of processed messages. Events also need to survive a crash between saving and publishing, which is what the outbox is for. In this example, the infrastructure would also need to write the aggregate’s Events to the outbox during the save and then clear them.
Repositories
A repository gives the application the illusion of a collection of whole aggregates, hiding how they’re stored.
There’s one per aggregate root that needs to be retrieved, not one per table. IStockItemRepository above returns a complete StockItem with its reservations. There’s no IReservationRepository, because loading or saving a reservation on its own would bypass the rule the root exists to protect.
Repositories also aren’t the place for every read. A dashboard doesn’t need to rebuild aggregates, so give it a query that returns exactly the shape it needs. I’ve written about what makes a repository worth having with EF Core.
The Anemic Domain Model
An anemic domain model has objects that carry data but little behavior, with the rules living in services that manipulate them.
Martin Fowler named it as an anti-pattern in 2003.[8] It tends to look like this:
// In some service, hoping every other service does the same check
int reserved = item.Reservations.Sum(r => r.Quantity);
if (item.OnHand - reserved >= quantity)
item.Reservations.Add(new ReservationRow { Quantity = quantity });
Here the classes have domain names and public setters, and the invariant is a convention. The second caller that forgets the check is your bug. The fix is the Reserve method above.
This doesn’t mean all logic belongs in entities. Application services coordinate work (load, call, save), some domain operations don’t naturally belong to any one object, and a CRUD screen with no rules has nothing to put in a rich model. The problem is paying for a domain model and then keeping the domain somewhere else.
Common Misunderstandings
| You may hear this | A more accurate version |
|---|---|
| “Each bounded context is a microservice.” | A context bounds a model. Deployment is a separate decision. |
| “Ubiquitous language means one company glossary.” | The language is consistent within a context, not across all of them. |
| “An aggregate is a group of related objects.” | It’s a consistency boundary around an invariant. |
| “The aggregate root is the parent table.” | It’s the only entry point for changing what’s inside the boundary. |
| “Every table gets a repository.” | Repositories are per aggregate root. |
| “An adapter is an anticorruption layer.” | Only if it translates the foreign model into yours. |
| “We use DDD; we have entities and repositories.” | Without language and boundaries, you have the patterns’ names. |
| “DDD should apply to the whole system.” | Spend the effort on the core domain. |
Where to Start This Week
- Pick one overloaded word in your codebase (
Customer,Order,Product,Account). Ask people from two departments to define it, and note where the answers diverge. If those conversations are hard to get or hard to run, Jimmy Nilsson’s tips for collaborating with domain experts are a practical place to begin.[9] - Draw the context map you actually have, including legacy systems and third parties. Mark who can force a change on whom.
- Describe your core domain in one sentence. Compare it with where your most careful design work has gone.
- Choose one aggregate and write down its invariant. Then search for every place that changes its data without going through the root. The DDD Crew’s Aggregate Design Canvas is one tool for thinking through invariants, concurrency conflicts, and size.[10]
- Check your transactions. List the use cases that save more than one aggregate, and ask a domain expert how quickly each rule really needs to be true.
- Replace one primitive that has rules attached, such as a SKU or a money amount, with a value object.
- Rename one class or method to the words the business uses.
None of these requires a rewrite or permission to “do DDD.”
Would Your Domain Expert Recognize It?
Show a domain expert the class and method names from your core domain, without the method bodies. StockItem.Reserve, Release, Dispatch, and WriteOff should start a conversation about their work. They might tell you that nobody says “dispatch,” or that a write-off needs approval. That’s the model getting better.
If what they see is ProductManager.UpdateData and OrderHelper.ProcessStatus, the business is somewhere else, probably in the heads of whoever has been around longest. A domain expert should be able to recognize their business in your class and method names. It won’t prove the design is right, but failing that test is a good reason to look closer.
References
- Eric Evans, Domain-Driven Design: Tackling Complexity in the Heart of Software, Addison-Wesley. His free Domain-Driven Design Reference (2015) summarizes the patterns and marks the terms introduced since the book.
- Jan Stenberg, Defining Bounded Contexts: Eric Evans at DDD Europe, InfoQ, June 26, 2019.
- Vaughn Vernon, Implementing Domain-Driven Design, Addison-Wesley, 2013.
- Microsoft. Implement value objects, Microsoft Learn, 2022.
- Vladimir Khorikov, C# 9 Records as DDD Value Objects, Enterprise Craftsmanship, November 24, 2020.
- Microsoft. Prepare .NET libraries for trimming, Microsoft Learn, 2025.
- Vaughn Vernon, “Effective Aggregate Design,” 2011: Part I, Part II, and Part III.
- Martin Fowler, AnemicDomainModel, November 25, 2003.
- Jimmy Nilsson, Tips for developers on improving collaboration with domain experts, April 22, 2026.
- DDD Crew, Aggregate Design Canvas, GitHub.
