I am building a system to keep track of Employees. In the system, for each employee, I also keep track of family members AND Next of Kin. As I was coding the employee object, it struct me that I am going to need about 90% of the same code for a relative (family member) object and a Next of Kin object. So my question is:
Should I build a generic Contact Object with all the basic data for a person. Then inherit from that to build a employee object, relative object and Next of Kin object?
Thanks in advance.
Inheritance should be based on behavior not data. Properties are data not behavior. If your object shares behavior, inheritance can be considered. However, keep in mind that you should favor composition over inheritance.
Thanks for the response.
I had soon come to a similiar conclusion after writing that but I left it just in case someone had a different experience.
Copyright (c) Marimer LLC