proper design - Order & OrderLineItemList

proper design - Order & OrderLineItemList

Old forum URL: forums.lhotka.net/forums/t/11280.aspx


TSF posted on Wednesday, April 04, 2012

From what I recall in my reading of the e-books, if you have an Order object, which also uses a list of line items, you would generally have a property of type OrderLineItemList (which in turn contains OrderLineItem objects).  Is this correct?

Is there any reason to consider exluding the OrderLineItemList from the Order object, and instead use a "getter" or UnitOfWork object to retrieve both of them together?  I ask because folks in my group are having that discussion.

As best I can tell, if an Order object is always going to consume line items, then a property of type OrderLineItemList should be included in the Order object.  I don't see a reason to create a wrapper ("getter") object that pulls both when the Order object could have referenced the OrderLineItemList in the first place.

JonnyBee replied on Wednesday, April 04, 2012

My vote is for having orderlineitems as a property of the order object. 

This way the order object can for calculations like OrderTotal, Discount and also know if any childh as broken rules.

TSF replied on Wednesday, April 04, 2012

Good point about the calculations.  I didn't mention that as I was discussing with my team.  I don't see what is gained by separatin them out, but having not used CSLA too long I don't want to assume that I know 100% the right way to go about it.  Thanks.

Copyright (c) Marimer LLC