OOP Design of items in a Point-of-Sale system

Posted by Jonas on Stack Overflow See other posts from Stack Overflow or by Jonas
Published on 2010-04-13T12:07:32Z Indexed on 2010/04/13 12:13 UTC
Read the original article Hit count: 515

I am implementing a Point-of-Sale system. In the system I represent an Item in three places, and I wounder how I should represent them in OOP.

First I have the WarehouseItem, that contains price, purchase price, info about the supplier, suppliers price, info about the product and quantity in warehouse.

Then I have CartItem, which contains the same fields as WarehouseItem, but adds NrOfItems and Discount.

And finally I have ReceiptItem, thats contains an item where I have stripped of info about the supplier, and only contains the price that was payed.

Are there any OOP-recommendations, best-practices or design patterns that I could apply for this? I don't really know if CartItem should contain (wrap) an WarehouseItem, or extend it, or if I just should copy the fields that I need. Maybe I should create an Item-class where I keep all common fields, and then extend it to WarehouseItem, CartItem and ReceiptItem. Sometimes I think that it is good to keep the field of the item and just display the information that is needed.

© Stack Overflow or respective owner

Related posts about oop

Related posts about object-oriented-design