3 ms·
Subclassing the Usertype is a wrong solution here anyway. In fact this is a classic OO trap. Whether a user is an admin or not is a role of the user. So a bet
by ensiferum 5y ago
Subclassing the Usertype is a wrong solution here anyway. In fact this is a classic OO trap. Whether a user is an admin or not is a role of the user.
So a better class relationship is
User has a Role. Role can be an interface class with multiple implementations.
This design trivially lends itself for example to a use case where the user holds multiple roles. The classic OO design would use some form of "multiple" inheritance resulting in complicated class hierarchy.