Objects and design properties

What is the best practice to implement the following:

  • we have classes Order

    and OrderItem

    as parent-child.
  • The class OrderItem

    provides the propertyCost

  • In the OrdersList form, we should see MaxCost

    column = max (cost) from the collectionItems

I only found one useful solution here that does not violate the DDD concept: add a regular property MaxCost

to the class Order

and update it every time the list of items is updated.

Is there another way?

+1


source to share


1 answer


Perhaps, but you have to ask yourself why. In terms of the domain, does it "care" if you repeat this? Or are you letting the programmer's domains creep in your problem area?



One more thing - consider making the "max item value" part of the OrderItems collection and hiding HOW you get it from the rest of the system.

+1


source







All Articles