Sidias-Korrado
Sidias-Korrado

Reputation: 403

Modeling Object connections in DDD

Suppose i have two classes:

What connection is the correct one from the standpoint of DDD?

  1. OrderItem containing a field referencing the Order
  2. Order having a field - collection of OrderItems

Is a field referencing another object interpreted as a dependency?

I am trying to understand DDD better.Thanks.

Upvotes: 0

Views: 66

Answers (1)

Joonas Lindholm
Joonas Lindholm

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

Related Questions