Question

If i have a system for organising a schedule for pilots and the plane they fly for a job. And a manager for organising the schedule. But the manager is also a pilot. Do i need two seperate child classes of user as pilot + manager. Or would it be more practical to just use an attribute of isManager in the pilot class for example? Or would the manager be a child of pilot?

And if the schdule class is a composition to system, would the method for creating a new schedule have to be in the system class?

Was it helpful?

Solution

Honestly, it depends on the requirements of the application and how you want to implement it as there could be no right or wrong answer. Pilot and Manager could be separate generalizations of the User class. User could also be a unary relationship. Who's to say you couldn't put an isPilot field in the User class? In the end it may be more practical to split the two as child classes of User. I know I would do it this way when coding them, by having User as my base class and then have Pilot and Manager extend User.

You could have something like this:

enter image description here

Or if a manager is always a pilot you could do this:

enter image description here

Personally I would implement the former because what if a manager comes along who isn't a pilot? Again, like I said it depends on the requirements of the application and how you want to implement it. Neither way is wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top