2 ms·
If you need to mix them up, there is bunch of options. It all depends on what you need to do, and what language you are using, but usually there should be simpl
by mic47 8y ago
If you need to mix them up, there is bunch of options. It all depends on what you need to do, and what language you are using, but usually there should be simple solution to this.
For example, if you simply want to have functions that works for both of them (so that you don't duplicate code), you can either create function from Manager to User (so that you can reuse functions for users), or use whatever polymorphism stuff your language support (polymorphic function, OOP, ...).
If you want to mix User/Manager in same collection (or have function that returns any of those), OOP can help too (Manager is "child" of User). If your language have sum types, you can use those (have additional type "User or Manager", and accompanying matching/extraction function).
In some languages you can do this with no runtime overhead (i.e. the additional type will be erased during runtime, as it's already type checked).