Question

I think the domain model is just a set of classes, and in run time, for different situation, we can use those classes to build different class diagram (or object graph)

I'm not sure about this understanding. Maybe the domain model author (Martin Fowler) means that .

All the domain model class/object can only form ONE class diagram.

Was it helpful?

Solution

The domain model is composed of classes (for class-oriented languages anyway). An object graph is a bunch of objects where they have references you can follow to traverse from one object to another. You can build an object graph using domain model classes.

So you could have a domain model with classes for Customer, Order, and LineItem, where a customer can have many orders, and each order can have many line items. Let's say the customer object would have a list of orders, the order would have a reference back to its customer, the order would have a list of details, each detail would have a reference back to its order. Then you can retrieve an order and traverse to its customer and to its details. That order would be represented by one object graph (or Aggregate, to use the Domain-Driven Design terminology). If you pull up a different order you would get a different object graph.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top