I'm fairly new to Object Oriented Programming, so here's what I'm wondering.
I'm working on a Contact Management system, where a contact can either be Person or a Business. My thinking is to have a base class called Contact and two classes derived from it, Person and Business.
In my database, I'd like to store all the information in one table and distinguish the contacts by a foreign key field, ContactTypeID for example.
At times in my code, I need to fill a collection of Contacts, including a mix of People and Businesses. For example, I may be looping through a result set and creating the objects as I loop. In such an example, what's the best way to determine which object I should be creating?
Adding a SELECT CASE item(i).ContactTypeID seems to defeat the purpose of OOP because if I ever decide to add a third contact type (or fourth), updating the code would become a nightmare.
I'm wondering if anyone has encountered a similar scenario and could shed some light on the matter.
Thanks in advance,