Reputation: 292
What is the best practice to implement the following:
Order
and
OrderItem
as parent-child. OrderItem
provides property Cost
MaxCost
column = max(cost)
from Items
collectionI found only one useful solution here which won't break the DDD concepts: to add a usual property MaxCost
to the class Order
and to update it each time when items list updates.
Is there another way?
Upvotes: 1
Views: 181
Reputation: 112376
Probably, but you have to ask yourself "why?". From the standpoint of the domain, does it "care" if you are recomputing this repeatedly? Or are you letting programmer-domain creep into your problem domain?
One other thing --- consider making "max cost of items" part of the collection of OrderItems, and hiding HOW you get it from the rest of the system.
Upvotes: 1