Suppose I have the following problem:
Could someone review this design?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
You're using subclassing when instances will work fine and actually better — the users should be instances of User (or instances of an more general Person even better) rather than subclasses of User, and, let's also assume that the departments should be instances of Department rather than subclasses of Department.
People's roles change but they stay the same person.
The association between user and department is just that, an association, with 1:N mappings between User and Department.
You should only subclass if you need to:
add additional data members but that only apply to one kind of department or user — meaning that you cannot add them to the base class as that would be somehow inappropriate for others
provide overriding behaviors that differentiate one department or user from another.
If you can capture the concept of different users and different departments by having a different
Name in the base class, then all you need are instances not subclasses.
Further, if you need to dynamically add a user or a department, instances work great as you can do that at runtime but subclasses don't, so you'd have to revise the program for each such addition.