Domain-Driven Design: Ubiquitous Language, from business vocabulary to code
Build a shared language that enables decisions. We will explore reservations, logistics, and education to detect ambiguities, write precise examples, and evolve names, contracts, and tests with AI assistance.
The indicator keeps the furthest percentage explored; marking the article complete is your choice.
An operations person says a reservation is confirmed. The payments team understands that it has already been charged. The developer interprets it as a row with confirmed = true. All three believe they are talking about the same thing, until a customer arrives and discovers their room is unavailable.
The problem started before the code. A shared word concealed different commitments.
Ubiquitous Language is a language built and used by people who know the business and people who develop the software, within a Bounded Context, the boundary where the model maintains a consistent meaning. It must also appear in the code. Reference: Martin Fowler.
The following working approach and its examples are practical recommendations: there is no universal glossary we can download for every company.
Useful vocabulary lets us anticipate consequences
“Confirmed” is useful only if we know what it permits. In our fictional hotel, we agree that a confirmed reservation guarantees accommodation, although payment may be made on arrival. For an activity with limited tickets, however, confirmation might require accepted payment.
We do not correct that difference by imposing a company-wide definition on every application. We clarify the meaning where it applies and make translation explicit when two areas collaborate.
To begin, we ask what happens before and after confirmation. Can it be canceled? Is capacity released? Who can reverse it? What is communicated to the guest? Each answer brings the conversation closer to verifiable behavior.
A good name allows an expectation to be expressed. If someone executes confirmReservation, they should understand the commitment the system has just made.
Scenario 1: a temporary hold is not a confirmed reservation
Imagine a platform that holds a place for ten minutes while payment is completed. The first model uses Reservation for everything and an active field to indicate whether it “still works.”
The word active mixes different questions: whether the hold expired, whether payment was accepted, and whether the participant retains their place. Before adding more booleans, we propose distinguishing hold and confirmation.
Hold:
Sets capacity aside until an expiration instant.
Does not guarantee participation after that instant.
Confirmation:
Commitment accepted by the system after verifying
the conditions agreed for the activity.
Cancellation:
Withdraws a confirmation and applies the refund policy.
Now we can discuss a situation previously hidden: the provider accepts payment at 10:11 and the hold expired at 10:10. Do we confirm anyway, find another place, or initiate a refund? The vocabulary reveals a pending decision; it does not invent it.
If the business has not chosen, we document alternatives. Generating code with AI before resolving this can turn an assumption into a rule that is hard to detect.
Bring a small agreement into code
For a self-contained example, let us agree that a hold is valid when the current instant is strictly before expiration. We will use integer milliseconds; we are not solving calendars or local times.
The name isValidAt requires the evaluation instant to be passed. The test at the exact expiration writes down an agreement that “lasts ten minutes” did not express precisely enough.
The example protects a local interpretation. Accepting a concurrent confirmation requires persistent coordination in addition to this method.
Scenario 2: dispatching, delivering, and receiving
A store marks an order as sent when it generates the label. The carrier considers the parcel dispatched when it physically receives it. Customer support interprets delivered as received by the buyer.
If we exchange status: "sent" without clarification, each team may display a different promise. We need to identify facts: label generated, parcel handed to the carrier, delivery attempt, and confirmed receipt.
We will not necessarily create a state for every technical scan. First we ask which ones change business decisions. Generating a label might allow documents to be printed, but not enable a claim for a transit delay.
In the integration, we would preserve the external meaning and define its mapping. An unknown status should not automatically become “delivered” or “pending.” It may require review and an explicit representation of uncertainty.
This scenario shows that a dictionary of literal translations is insufficient. We also need to know who has authority to assert the fact and what evidence supports it.
Scenario 3: finishing a lesson and passing a course
In education, “completed” can mean watching a video, submitting an activity, or passing an assessment. A screen showing one hundred percent does not necessarily explain which occurred.
We can distinguish consumption progress, submitted activities, and passing requirements. A student could finish every lesson and still not pass the course because a required assessment is missing.
The team would review phrases such as “issue a certificate upon completion.” Complete what? Do courses allow requirements to change after enrollment? Is the criterion evaluated using the current version or the one agreed upon at enrollment?
The answers may lead to concepts such as CompletionCriteria or CoursePassed, but those names must follow the conversation. We would not add an interchangeable policy simply because the pattern is appealing.
How to build the language with the team
I recommend working with three materials: real situations, terms in use, and examples that contradict an interpretation. In a brief meeting, one person explains a journey and another tries to repeat it using precise words. When interpretations diverge, we record the question.
A term record can include meaning, context, a valid example, a counterexample, and consequences. It is also useful to flag terms to avoid: if active proved too ambiguous, documenting that prevents its reappearance on another screen.
The record does not replace conversation or need approval through a heavy process. Its usefulness lies in enabling a newcomer to make the same decision in the same scenario.
I would not require reviewing every term before implementing. I would start with those involved in important rules, rejections, and public commitments.
How to evolve names without breaking contracts
Discovering a better term does not require renaming everything in a single delivery. We can first change the internal model and maintain an adaptation of the existing public contract. If the meaning also changes, a simple textual replacement would be dangerous.
For example, replacing confirmed with paid breaks expectations for those who understood that confirmation did not require payment. Behavior, historical data, messages, tests, and consumers must be reviewed.
In a small migration, we would search for the old term with rg, classify each occurrence, and distinguish internal names from persisted fields or APIs. Then we would update the scenarios and run their tests.
Acceptance should check that decisions remain correct. The compiler finding no occurrences of the previous name is useful verification, but insufficient.
Work with AI without fabricating agreements
AI can help uncover inconsistencies in documentation and code. It cannot independently confirm the business commitment the organization wants to make.
Analyze these reservation journeys and their current names.
For each ambiguous term:
- show two interpretations consistent with the text;
- explain which observable outcome would change;
- formulate a question for the business person;
- propose a provisional name for each alternative.
Separate confirmed facts from assumptions.
Do not choose an expiration or refund policy for us.
After resolving the questions, suggest test scenarios
and locate affected names in the supplied code.
To evaluate the response, I would look for concrete evidence. A generic recommendation such as “improve names” is not actionable; showing that a screen says paid while the Use Case only reserves capacity does provide something to investigate.
Signs that the language is helping
Names let us follow a journey without constantly translating between business and code. Tests distinguish states that previously seemed equivalent. Uncertainties become concrete questions and contracts state what they promise.
Not everyone needs to speak like the code, nor does code need to reproduce every colloquial expression. We seek shared precision for the decisions that matter. When the team understands why an expired hold is not equivalent to a canceled reservation, the model is already adding value before another abstraction is introduced.
Integrate the collection by building an order API with TypeScript, Express, Zod, and SQLite. Includes project files, domain rules, events, version control, Vitest tests, and commands to run and verify it locally.
Learn to guide AI agents with business rules, context boundaries, and verifiable criteria. A TypeScript case shows how to prepare instructions, protect Order, design tests, and review changes without delegating architectural judgment.
Compare a modular monolith with separating Sales, Payments, and Inventory. Design contracts in TypeScript and Express and understand partial failures, eventual consistency, idempotency, Outbox, and Sagas without introducing complex infrastructure.