Introduction to Domain-Driven Design (DDD)
From the ddd curriculum
TL;DR
Domain-Driven Design (DDD) is an approach to software development that focuses on deeply understanding the core business domain. It helps you create software that directly reflects and solves real-world business problems. By aligning your code with the language and concepts of the business experts, DDD leads to more maintainable and effective systems.
1. The Mental Model
Think of DDD as building software using the exact vocabulary and concepts of the business you're serving. Instead of just coding features, you're modeling the business world within your software, ensuring that the software truly speaks the business language.
2. The Core Material
DDD helps you manage the complexity of large software projects by putting the domain – the subject area of the business – at the center of development. It emphasizes collaboration between domain experts (people who understand the business) and software developers.
Core Concepts

Photo by Dimitri on Pexels
-
Ubiquitous Language: This is a shared language developed by the team (developers and domain experts) that is used consistently everywhere: in conversations, documentation, and most importantly, in the code itself. If a domain expert calls something a "shipment," your code should have a
Shipmentclass, not aPackageorDeliveryItem. -
Domain Model: This is an object-oriented model of the business domain. It's not just a database schema; it represents the behavior and relationships of the business concepts. The domain model captures the "rules of the game" for the business.
-
Bounded Context: This is a key concept for managing complexity. A large business domain can be broken down into smaller, distinct areas, each with its own specific domain model and Ubiquitous Language. Within a Bounded Context, a term means one thing, but it might mean something slightly different or have a different context in another part of the business. For example, a "Product" in an e-commerce "Catalog Management" context might have attributes like
descriptionandprice, while a "Product" in a "Shipping Logistics" context might only care aboutweightanddimensions.```mermaid
graph TD
A["Overall Business Domain (e.g., E-commerce)"] --> B["Bounded Context: Catalog Management"]
A --> C["Bounded Context: Order Processing"]
A --> D["Bounded Context: Shipping Logistics"]B --> B1["Ubiquitous Language (Catalog)"] B --> B2["Domain Model (Product, Category)"] C --> C1["Ubiquitous Language (Order, Customer)"] C --> C2["Domain Model (Order, LineItem)"] D --> D1["Ubiquitous Language (Shipment, Carrier)"] D --> D2["Domain Model (Shipment, Package)"] B -- "Anti-Corruption Layer (ACL)" --> C C -- "Context Map" --> D```
-
Entities: These are objects that have a unique identity and can be tracked over time. Even if their attributes change, they are still the "same" entity. For example, a
Customerentity has a unique ID, even if their address or name changes. -
Value Objects: These are objects that describe a characteristic or attribute but have no conceptual identity. They are defined by their attributes, and if all their attributes are the same, they are considered equal. Think of
Money(e.g., "
Frequently asked about Introduction to Domain-Driven Design (DDD)
Study this next
Get the full ddd curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Save this course free