Reputation: 403
Suppose i have two classes:
What connection is the correct one from the standpoint of DDD?
Is a field referencing another object interpreted as a dependency?
I am trying to understand DDD better.Thanks.
Upvotes: 0
Views: 66
Reputation: 156
I'll make an assumption here and consider your Order class to be the aggregate root.
In that case you would go with the option 2, meaning an Order then would contain a collection of OrderItems. And OrderItems could only be added via Order Aggregate root, ie. via method Order.AddOrderItem().
Upvotes: 1