noetic
noetic

Reputation: 292

Entities and calculated properties

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 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

Answers (1)

Charlie Martin
Charlie Martin

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

Related Questions