Domain-driven design (DDD) is an approach to the design of software, based on the two premises that complex domain designs should be based on a model, and that, for most software projects, the primary focus should be on the domain and domain logic (as opposed to being the particular technology used to implement the system). The term was coined by Eric Evans in his book of the same title.
In the book Domain-Driven Design a number of high-level concepts and practices are articulated, such as ubiquitous language meaning that the domain model should form a common language for describing system requirements, that works equally well for the business users or sponsors and for the software developers. The book is very focused at describing the Domain layer which is one of the common layers in an object-oriented system with a multilayered architecture. In DDD a number of specific software design patterns are useful, such as:
- Entities (a.k.a. Reference Objects): An object in the domain model that is not defined by its attributes, but rather by a thread of continuity and identity.
- Value Objects: An object that has no conceptual identity. These objects describe a characteristic of a thing.
- Repository: methods for retrieving domain objects should delegate to a specialised 'repository' object such that alternative implementations may be easily interchanged.
- Factory: methods for creating domain objects should delegate to a specialised 'factory' object such that alternative implementations may be easily interchanged.
- Service: When an operation does not conceptually belong to any object. Following the natural contours of the problem, you can implement these operations in services. The Service concept is called "Pure Fabrication" in GRASP.
Relationship to other ideas
Object-oriented analysis and design: Although in theory, the general idea of DDD need not be restricted to object-oriented approaches, in practice DDD seeks to exploit the powerful advantages that object-oriented techniques make possible.
Model-driven architecture (MDA): While DDD is compatible with MDA, the intent of the two concepts is somewhat different. MDA is concerned more with the means of translating a model into code for different technology platforms than with the practice of defining better domain models.
POJOs and
POCOs: POJOs and POCOs are technical implementation concepts, specific to the
Java and
.NET framework respectively . However, the emergence of the terms POJO and POCO, reflect a growing view that, within the context of either of those technical platforms, domain objects should be defined purely to implement the business behaviour of the corresponding domain concept, rather than be defined by the requirements of a more specific technology framework.The
naked objects pattern: This pattern is based on the premise that if you have a good enough domain model, the user interface can simply be a reflection of this domain model; and that if you require the user interface to be direct reflection of the domain model then this will force the design of a better domain model.
Domain-specific programming language (DSL): DDD does not specifically require the use of a DSL, though it could be used to help define a DSL.
Aspect-oriented programming (AOP): AOP makes it easy to factor out technical concerns (such as security, transaction management, logging) from a domain model, and as such makes it easier to design and implement domain models that focus purely on the business logic.
Preliminary Design and
Requirements Analysis: Domain modelling is not a new concept. Understanding the domain space was the initial analysis goal before jumping into design or implementation in most of the text books. Historically, and in reality, developers shunned domain modelling, preferring to dive quickly into implementation. Moreover, many main stream developers struggled with the distinction between analysis models and design models (most design texts warning of the confusion). With modern frameworks and auto generated code domain modelling is simply what was old and is now new again - and flavour of month. Of note DDD might see resurrection of
Test Driven Development (or as it has become
Behavior Driven Development) as DDD provides classes closer to the requirements model and therefore the functional baseline for the software system (if someone could autogenerate test code from JPA annotations).
Software tools to support domain-driven design
Practicing DDD does not depend upon the use of any particular software tool or framework. Nonetheless, there is a growing number of open-source tools and frameworks that provide support to the specific patterns advocated in Evans' book and/or the general approach of DDD. Among these are:
References
External links