Domain Driven Design Context Mapping Created: 10 Jan 2026 Updated: 10 Jan 2026

Published Language

In Domain-Driven Design (DDD), a Published Language is a strategic design pattern used to define the medium of communication between different Bounded Contexts.

In simpler terms, it is a shared, standardized, and well-documented data structure (or schema) that two or more contexts agree to use when exchanging information.

1. The Purpose of a Published Language

Within a single Bounded Context (e.g., the "Ordering" context), the internal domain objects are often complex, contain rich behavioral logic, and change frequently as business rules evolve.

If you expose these complicated internal structures directly to other outside contexts, you create Tight Coupling. Every time you change your internal code to fix a bug or add a feature, you risk breaking every other system that communicates with you.

A Published Language acts as a buffer zone or a translation layer. It decouples your internal implementation details from the external contract you provide to the world.

Analogy: Imagine two countries (Context A and Context B) that speak different local languages (Internal Models). When their diplomats need to sign an official agreement, they don't use local slang. They agree on a common diplomatic language (e.g., English) and a specific, standardized document format. This agreed-upon document format is the "Published Language."

2. Relationship with Other DDD Concepts

A Published Language rarely exists alone; it works in tandem with other patterns:

  1. Relationship with Ubiquitous Language: The Published Language is essentially a specialized, public subset of a context's Ubiquitous Language. It doesn't contain every detail found internally, only the concepts necessary for the outside world to understand.
  2. Relationship with Open Host Service (OHS): The OHS is the mechanism for access (the API endpoint or the "door"). The Published Language is the format of the data that passes through that door (the "contract" or Data Transfer Object - DTO).


3. Practical Example: E-Commerce Order vs. Shipping

Let's consider an E-commerce system with an Order Context (Upstream/Data Producer) and a Shipping Context (Downstream/Data Consumer).

A. The Internal Domain Model (Hidden inside the Order Context)

The Order context's internal model is complex. It cares about complex pricing rules, tax calculations, and inventory reservations.

// The complex internal structure known ONLY to the Order Context.
internal class OrderAggregate
{
public Guid Id { get; private set; }
// Contains tax rates, cost basis, supplier info, etc.
public List<RichOrderItem> Items { get; private set; }
// Complex business logic objects
public AppliedDiscountPolicy DiscountRules { get; private set; }
public InternalPaymentStatus PaymentStatus { get; private set; }
// ... many more internal fields
}

B. The Published Language (The Public Contract)

The Shipping team doesn't care about how you calculated taxes or what discount policy was applied. They only need to know "Where is it going?" and "How heavy is it?".

Therefore, the Order context translates its internal aggregate into a stable Published Language (DTO) specifically designed for external consumption.

// The Published Language: A stable contract used to communicate externally.
// This is often encoded as JSON, Protobuf, or XML.
public record ReadyForShippingEvent(
Guid OrderId,
string CustomerName,
ShippingAddressDto Destination,
List<PackageContentsDto> Items,
double TotalWeightKg
);

// Simple structures defining the shared language components
public record ShippingAddressDto(string Street, string City, string ZipCode, string CountryCode);
public record PackageContentsDto(string ProductSku, int Quantity);

Summary: Why Use a Published Language?

BenefitDescription
DecouplingThe Upstream context can completely refactor its internal domain model or database schema without breaking downstream consumers, as long as it keeps producing the agreed-upon Published Language format.
StabilityA Published Language acts as a contract. It is designed to be stable and resistant to change. If it must change, it is usually handled through formal versioning (e.g., v1, v2).
InteroperabilityDownstream teams don't need to understand the Upstream's complex code or domain logic. They only need to understand the documented schema (like an OpenAPI/Swagger spec or a Protobuf definition).


Share this lesson: