I would like to know if somebody has a good sample about how to organize a UML class diagram when using Domain-Driven Design.
I really don't know how to make fit entities with repositories and services.
A domain class diagram is a type of UML diagram that shows the relationships between various classes in a software system. A domain class diagram is a type of UML diagram that shows the relationships between various classes in a software system. It is used to model the static structure of a system.
An aggregate is a domain-driven design pattern. It's a cluster of domain objects (e.g. entity, value object), treated as one single unit. A car is a good example. It consists of wheels, lights and an engine.
Domain-driven design (DDD) is a software development philosophy centered around the domain, or sphere of knowledge, of those that use it. The approach enables the development of software that is focused on the complex requirements of those that need it and doesn't waste effort on anything unneeded.
The UML diagrams that I end up with for DDD are usually hand drawn, informal and don't strictly adhere to all the guidelines. From the perspective of UML, entities, repositories and services are all simply classes; classes could be marked with a stereotype for clarity.
Furthermore, I don't place too much emphasis on class diagrams alone. It is often more fruitful to consider the model from a behavioral perspective, which is where sequence diagrams can be helpful, though they can quickly become too technical. Class diagrams can help you identify aggregates and entities, but they can also lead you astray by placing too much emphasis of the nouns as opposed to the verbs.
Another important type of diagram in DDD is a context map which can be viewed as a class diagram for bounded contexts. There aren't any explicit UML practices for expressing context maps and as a result an informal approach works best.
Overall, what has worked for me is low friction, low ceremony, and informal. Use boxes to represent concepts and lines between them to represent relationships. Anything beyond that can certainly be helpful but it shouldn't be at the cost of the other aspects.
You should also understand the purpose of the diagram. Are they for facilitating the design and modeling process? Are they for documentation? For sparking conversation? For communication? Each of those reasons may have specific constraints.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With