My teacher gave us a homework to draw a class diagram using something like this
class PersonRole{}
class Employee{
isA PersonRole;
}
class Manager {
isA Employee;
0..1 -- * Employee;
}
I know in order to draw a reflexive association, both instances has to have same class(is that correct?)
But in this instance, manager inherits from employee, and employee inherits from personrole.
So can I say both of their class are personrole and draw a reflexive association between them?
If not, do I just Draw generalization and association?
i tried to draw normal reflexive line like this
but it feels weird
I also tried this
Feels OK but I wonder if using reflexive is possible
Your first attempt uses a reflexive association. It is not wrong but does not at all correspond to your design:
personRole
.Your second design doesn't use reflexive associations, and corresponds to your narrative. There is no issue having an association and a generalization between the same classes.
A third option could use a reflexive association on employee, but keep manager as a specialisation on employee. This design deviates from the narrative, could allow managers to have different properties and behaviours. But it implies also that employees could report to non-managers (e.g.team leads that have not a formal management role).