samedi 27 avril 2019

How to design this relationship between classes?

I recently had an object/class design question. The problem was this:

"You have an University and it has employees, which can be either Student or Teacher."

They asked me to design only the relationship of the employees so I made a simple inheritance diagram

Then he asked me what happens if Student can be a Teacher, it can't inherit from Employee and Teacher. I couldn't answer so he designed a solution with a Role class.

Another solution could've been using Decorator Pattern?

Diagrams here: https://imgur.com/a/GgEQimb since I can't post images yet.

¿What dou you think of these approaches?

Thanks

Aucun commentaire:

Enregistrer un commentaire