What is the best practice to implement the following:
- we have a classes
OrderandOrderItemas parent-child. - Class
OrderItemprovides propertyCost - On the OrdersList form we have to see
MaxCostcolumn = max(cost) fromItemscollection
I 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?
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.