OrderItem with specific characteristics

OrderItem with specific characteristics

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


Michael Hildner posted on Friday, July 07, 2006

Hi,

I'm pretty sure this has been discussed before, like here - http://forums.lhotka.net/forums/thread/2102.aspx - but I don't quite get it yet.

Let's say you have an OrderHeader (customer name, billing info etc.), that has two OrderItems associated with it. OrderItem #1 is a pair of jeans, OrderItem #2 is a T-shirt with a custom message printed on it.

In this example, the custom message is specific to that OrderItem, and never applies to a pair of jeans, sunglasses or other product items.

How do you design your OrderItem class(es?) to take into account extra information that is specific to a product item?

I'm pretty lost as to the class design as well as the database structure.

Any thoughts appreciated,

Mike

RockfordLhotka replied on Friday, July 07, 2006

I don't know if this is appropriate for you, but I've seen other people solve similar issues by having "DetailItem" objects as children of LineItem. So an Order has a collection of LineItem, and a LineItem has a collection of DetailItem.

Then if you have polymorphic LineItem types (http://www.lhotka.net/Articles.aspx?id=b8515cd9-7f8e-43df-9efd-cd958dfdc21a), each line item class can enforce its own rules about what (if any) detail items are allowed.

Copyright (c) Marimer LLC