views:

77

answers:

1

What is the best practice to implement the following:

  1. we have a classes Order and OrderItem as parent-child.
  2. Class OrderItem provides property Cost
  3. On the OrdersList form we have to see MaxCost column = max(cost) from Items collection

I found only one usefull solution here which won't break the DDD concpts: to add a usual property MaxCost to the class Order and to update it each time when items list updates.

Is there another way?

+1  A: 

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.

Charlie Martin