Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain-Driven Design Class Diagram

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.

like image 476
Maurício Lanza Avatar asked Dec 09 '12 20:12

Maurício Lanza


People also ask

What is domain class model diagram?

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.

What is domain-driven design example?

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.

What is meant by domain-driven design?

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.


1 Answers

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.

like image 73
eulerfx Avatar answered Sep 20 '22 11:09

eulerfx