Domain-Driven Design - Wikipedia
Domain-Driven Design - Wikipedia
Domain-driven design
Domain-driven design (DDD) is the concept that the structure and language of software code
(class names, class methods, class variables) should match the business domain. For example,
if a software processes loan applications, it might have classes such as LoanApplication and
Customer, and methods such as AcceptOffer and Withdraw.
DDD connects the implementation to an evolving model.[1]
Domain-driven design is predicated on the following goals:
placing the project's primary focus on the core domain and domain logic;
basing complex designs on a model of the domain;
initiating a creative collaboration between technical and domain experts to iteratively refine a
conceptual model that addresses particular domain problems.
Criticisms of domain-driven design argue that developers must typically implement a great
deal of isolation and encapsulation to maintain the model as a pure and helpful construct.
While domain-driven design provides benefits such as maintainability, Microsoft recommends
it only for complex domains where the model provides clear benefits in formulating a common
understanding of the domain.[2]
The term was coined by Eric Evans in his book of the same title.[3]
Overview
https://en.m.wikipedia.org/wiki/Domain-driven_design 1/6
Kinds of models
2021/8/30 Domain-driven design - Wikipedia
defined purely by the business behavior of the domain, rather than by a more specific
technology framework.
Similarly, the naked objects pattern holds that the user interface can simply be a reflection a
good enough domain model. Requiring the user interface to be a direct reflection of the
domain model will force the design of a better domain model.[4]
Domain-driven design has influenced other approaches to software development.
Domain-specific modeling, for instance, is domain-driven design applied with domain-specific
languages. domain-driven design does not specifically require the use of a domain-specific
language, though it could be used to help define a domain-specific language and support
domain-specific multimodeling.
In turn, aspect-oriented programming makes it easy to factor out technical concerns (such as
security, transaction management, logging) from a domain model, letting them focus purely on
the business logic.
Model-driven engineering and architecture
While domain-driven design is compatible with model-driven engineering and architecture,[5]
the intent behind the two concepts is different. Model-driven architecture is more concerned
with translating a model into code for different technology platforms than defining better
domain models.
However, the techniques provided by model-driven engineering (to model domains, to create
domain-specific languages to facilitate the communication between domain experts and
developers,...) facilitate domain-driven design in practice and help practitioners get more out
of their models. Thanks to model-driven engineering's model transformation and code
generation techniques, the domain model can be used to generate the actual software system
that will manage it.[6]
https://en.m.wikipedia.org/wiki/Domain-driven_design 3/6
2021/8/30 Domain-driven design - Wikipedia
While CQRS does not require domain-driven design, it makes the distinction between
commands and queries explicit with the concept of an aggregate root. The idea is that a given
aggregate root has a method that corresponds to a command and a command handler invokes
the method on the aggregate root.
The aggregate root is responsible for performing the logic of the operation and yielding either
a number of events, a failure response or just mutating its own state for that can be written to a
data store. The command handler pulls in infrastructure concerns related to saving the
aggregate root's state and creating needed contexts (e.g., transactions).
Event sourcing
Event sourcing is an architectural pattern which where entities do not track their internal state
by means of direct serialization or object-relational mapping, but by reading and committing
events to an event store.
When event sourcing is combined with CQRS and domain-driven design, aggregate roots are
responsible for validating and applying commands (often by having their instance methods
invoked from a Command Handler), and then publishing events. This is also the foundation
upon which the aggregate roots base their logic for dealing with method invocations. Hence,
the input is a command and the output is one or many events which are saved to an event
store, and then often published on a message broker for those interested (such as an
application's view).
Modeling aggregate roots to output events can isolate internal state even further than when
projecting read-data from entities, as in standard n-tier data-passing architectures. One
significant benefit is that axiomatic theorem provers (e.g. Microsoft Contracts and CHESS[7])
are easier to apply, as the aggregate root comprehensively hides its internal state. Events are
often persisted based on the version of the aggregate root instance, which yields a domain
model that synchronizes in distributed systems through optimistic concurrency.
Notable tools
Although domain-driven design does not depend on any particular tool or framework, notable
examples include:
Actifsource, a plug-in for Eclipse which enables software development combining DDD with
model-driven engineering and code generation.
CubicWeb, an open source semantic web framework entirely driven by a data model. High-
level directives allow to refine the data model iteratively, release after release. Defining the
https://en.m.wikipedia.org/wiki/Domain-driven_design 4/6
2021/8/30 Domain-driven design - Wikipedia
data model is enough to get a functioning web application. Further work is required to define
how the data is displayed when the default views are not sufficient.
OpenMDX, an open-source, Java-based, MDA Framework supporting Java SE, Java EE, and
.NET. OpenMDX differs from typical MDA frameworks in that "use models to directly drive
the runtime behavior of operational systems".
Restful Objects, a standard for mapping a Restful API onto a domain object model (where the
domain objects may represent entities, view models, or services). Two open source
frameworks (one for Java, one for .NET) can create a Restful Objects API from a domain
model automatically, using reflection.
See also
Event storming
Knowledge representation
Ontology (information science)
Semantic analysis (knowledge representation)
Semantic networks
Semantics
References
https://en.m.wikipedia.org/wiki/Domain-driven_design 5/6
2021/8/30 Domain-driven design - Wikipedia
External links
https://en.m.wikipedia.org/wiki/Domain-driven_design 6/6