i have a parent class Person, with children Employee, Member. at some point i will need an Employee to become an employee and a member at same time, holding all the attributes available for both employee and member. how could this be achieved while maintaining only one database record for that person who has moved from being Employee to being both Employee and a Member? i guess multiple inheritance could solve the problem by creating a new class that inherits from those two children, but i am using c#.
For some things, inheritance is just not the best choice.
If someone who is an Employee
can become a Member
or vice versa, and especially if someone can be both at once, this should probably just not be an inheritance relation in the first place.
I would change the Employee
and Member
classes into subclasses of a new component called something like Role
, and change the Person
class to have a field that is a set of Role
objects.
With this representation, someone can have both Employee
and Member
roles.