Suppose that we are developing some application that requires us to be able to manage customers and that those customers can be both natural and legal person. There are some different ways on which we can deal with it and I'm not sure which of them is the best regarding extensibility, code reuse and so on.
The first thing I thought was to construct two classes "NaturalCustomer" and "LegalCustomer". Then, the shared properties would be moved to a base class "Customer" and both NaturalCustomer and LegalCustomer would inherit from it.
The second thing I thought was "consider every customer as a natural person, and consider that a legal person customer is just a natural person that has one or more companies". In that case I would create a class "Customer" and then a class "CustumerCompany". If there are other companies in the application that share properties with CustomerCompany I would build a new class Company and inherit from it. In this approach there would be a zero-to-many relationship between Customer and CustomerCompany: a customer can have one or none companies.
I'm not really sure how to deal with this kind of problem. I'm just beginning with object oriented analysis and design and I'm still confused. The main problem is that if I select the first approach I wouldn't be really reusing lots of code. For instance, there could be other kinds of natural person in the app like "Employee" and it would share lots of properties with NaturalCustomer, and the same for companies, there could be companies like "Supplier" and it would share lots of properties with LegalCustomer and still I wouldn't be reusing it - so if I have to make a change on data that should be stored for companies I would have to change everywhere.
How do we deal in this kind of situation when multiple inheritance isn't allowed (that is I cannot make LegalCustomer inherit both from Customer and LegalPerson)?
Thanks very much in advance!