1

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?

nicwhitts
  • 190
  • 1
  • 3
  • 22

1 Answers1

0

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.

Dan
  • 2,701
  • 1
  • 29
  • 34
  • @nicwhitts if you feel it answers your question, could you mark it as answered? Thanks. – Dan Nov 26 '13 at 16:51
  • Accidently sent** Thanks for the reply: The spec doesn't mention anything about a manger not being a pilot i guess what is stated is only required. On your second diagram, doesn't Pilot also need to be associated to the schedule? In order for the pilot to view their schedule? – nicwhitts Nov 26 '13 at 16:52
  • Yes and so would plane, to get the plane schedules, which could be a many to many relationship. I was just showing a basic implementation, something to point you in the right direction. – Dan Nov 26 '13 at 16:57
  • I got another quick question if you could clear this up, lets say i added another class called airport. I would need an association from Pilot -> Airport and Airport -> Pilot (for pilots in airport) and one navigatable -> Manager (for airport's manager) But would i need it navigatable back to Airport from Manager if there is already one from Pilot -> Airport? Manager is inheritied from pilot like above – nicwhitts Nov 26 '13 at 18:56