The problem
Your model has a weakness: a Manager
of one Company could be Employee
of another, because nothing in your model says that the employment relationship with the Company
is the same for both classes.
Why? If you apply the UML generalization semantics:
Employee
has an association with Company
,
Manager
is a specialization of Employee
, and therefore inherits all its properties, operations and associations, including the association with Company
.
Manager
has in addition its own association with the Company
. So it has two distinct associations: the inherited one and its own one.
Potential solutions
It would be helpful to label the ends of the association, e.g. employer
/ employee
and company
/manager
:
The simplest solution could be to remove the association between Manager
and Company
, since it is inherited. But there is no easy way to tell that there must be a Manager
among the employees
. Moreover, there wouldn't be an easy way to find the Manager
of a Company
. So this solution does not appear appropriate.
Another solution would be to add a constraint that specifies that for the Manager
, manager.company
is the same than employee.employer
. Since a Manager
manages one and only one company
, no other manager could by deduction exist among the employees
. But this sounds somewhat artificial.
The best solution in my view is therefore to keep both associations but use UML smeantics to explain that company {subsets employer}
and manager {subsets employee}
Be aware that this solution requires 20 employees, since it makes clear that the manager is one amont the 20.
If you're interested to know more about subsetting, I advise you this artile about redefinition, specialization and subsetting of associations, which could also inspire you other variants.
Minor remarks
The aggregation are fine. However, aggregation is a modelling placebo since the UML specs clearly say page 110:
Precise semantics of shared aggregation varies by application area and modeler.
Therefore, I'd suggest to avoid them when possible. You could therefore as well use normal UML associations. Especially for the manager where there is only one.
Another remark made by qwerty_so in the comments is that the +
should be removed in +has
: The +
is about public visibility. It’s not the association itself that is public or private, but the association end (e.g. employer
and employee
in my proposal).