Let's say I have a base class User
that holds all the necessary info (login, name, mail ...). There's Administrator
class deriving from User
that can create new and delete existing User
s.
I need 3 more classes: Manager
, Worker
and Project
. Both Manager
and Worker
derive from User
but there's no need for additional members or methods within these which makes them empty classes.
In terms of visual representation I find this clear to understand if I aggregate Manager
and Worker
to the Project
like this:
The thing is that I'd also like Administrator
to have access to the list of all the Managers
and the list of Workers
. Also Project
should be able to return its Manager
and Worker
s. In C++ to get such list I'm afraid I would have check the class type of each User
to filter it out. I feel this is not the right way or is it?
A solution to this could be not creating Manager
, neither Worker
classes at all but rather adding a User
attribute called occupation/designation that would be a string. Then the filtering process would get more straightforward and probably less costly.
If I took this route I'd end up with inaccurate diagram in which multiple User
s are aggregated to the Project
(or multiple projects) and no way to distinguish between the manager and the workers.
Could somebody please shed some light on this topic and maybe provide some graphical example?