Summary
I cannot finish the original domain driven design doc by Eric Evans as it's too dry and sometimes lack of focus so I pivoted to this book to learn about DDD. DDD fits well into currently popular microservices trend. However, this book lacks sufficient examples and detailed tips on how to apply DDD to practical situations. The most important learnings of the book is: use ubiquitous within EPD, model domain in a well contained bounded context and map it to your team structure.
Raw Reading Notes
1. Use ubiquitous language to communicate between engineering, product , and stakeholder
2. write text message + diagram to illustrate models
3. Keep design and code in sync by referring to design while coding, and updating doc if necessary
4. Model driven design
1. Entities are objects with an identity, which remains the same throughout the states of the software. For these objects the values don’t matter, only the identifier. Only create Entities for the most important parts of the domain.
2. Value Objects are objects where we are only interested in it’s attributes. They don’t have an identity. It is recommended to make Value Objects immutable. Keep Value objects thin and simple.
3. Services provide functionality for the domain. Functionality that cannot be incorporated in Entities or Value Objects because it functions across several objects. Services can appear in each of the layers.
4. Modules are used as a method to organise related concepts and tasks in order to reduce complexity. Modules should be made up of elements which functionally or logically belong together.
5. An Aggregate is a group of associated objects which are considered as one unit with regard to data changes. Each aggregate has a root Entity and that is the only object accessible from the outside. Other object in the aggregate can only be changed by performing actions on the root, never directly on the other objects.
6. Factories can encapsulate the process of complex object creation. They are especially useful to create Aggregates.
7. Repositories encapsulate the logic for storing and retrieving objects. They hide the logic of for example a database, files or communication with an external service and may use for example caching.
5. Bounded Context: A model should be small enough to be assigned to one team. There is no formula to divide one large model into smaller ones.
6. Context Map: An enterprise application has multiple models, and each model has its own Bounded Context. It is advisable to use the context as the basis for team organization. A Context Map is a document which outlines the different Bounded Contexts and the relationships between them. (e.g. a high level architecture)