This is a general 'object-oriented design' question:
Suppose I'm writing code that tracks inventory. Let's say I have a class "Vendor" (which defines a supplier that items come from, e.g. "Left-Handed Screwdrivers, inc.") and a class "LineItem" (which defines a specific product. (e.g. "Cruftmatic #12 Left-Handed Screwdriver").
Now (and here's where I'm not too sure), let's further suppose that I have need of code to track a SPECIFIC item. For example, maybe I need to determine 'Left-Handed Screwdrivers, inc' sends us more faulty Cruftmatic brand #12 Left-Handed screwdrivers' than another supplier (say, 'Wacky Tools Warehouse', for example).
In short, I have an object that defines the Supplier, and an object that defines the properties of a particular type of item. Now I want to have a 'SpecificItem' object that includes information about the supplier that the particular item came from (perhaps along with 'SerialNumber' and such). To do this, do I want to:
A)Try to create a 'SpecificItem' class that instantiates an instance of the "Vendor" class within it? (Can you even do this?)
😎Create a 'SpecificItem' class that 'extends' LineItem, and copy most of the variables and some of the methods from the Vendor class into it as well?
C)Try to deal with the individual item with 'parallel' but separate Vendor and LineItem objects?
or
D)Bang my head on the table 5 times and take a deep breath, because I'm missing an obvious, elegant way to deal with this sort of thing?
Thanks for any help!