Domain-driven Design
Erscheinungsbild
Domain-driven design (DDD) is an approach to the design of software, based on two premises [1]:
- 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)
- Complex domain designs should be based on a model.
The term was coined by Eric Evans' book of that title[2]. The book articulates a number of high-level concepts and practices, such as:
- Ubiquitous language: 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.
plus a number of specific software design patterns, 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.
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.
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 the general approach of DDD and/or the specific patterns advocated in Evans' book. Among these are:
- Spring: provides dependency injection of services into domain objects.
- Naked Objects: implements the naked objects pattern; supports dependency injection; and provides re-usable implementations of the DDD concepts of Repository, Factory and Service.
- Castle Windsor/MicroKernel: an Inversion of Control/Dependency Injection container for the Microsoft.NET Framework to provide Services, Repositories and Factories to consumers.
References
External links
- Eric Evans on Domain Driven Design - Putting the Model to Work
- Jimmy Nilsson on Domain Driven Design
- Domain-Driven Design forum (English)
- Domain-Driven Design forum (Swedish)
- ↑ Definition on domaindrivendesign.org
- ↑ Evans, E., Domain-Driven Design - Tackling Complexity in the Heart of Software, 2004, Addison-Wesley