educative.io

Educative

Uni directional vs Bi directional Association between Airline management objects

Hi,

How is Flight assigned to Aircraft?
If Book Item is-a Book, then Flight is-an Aircraft. what is the difference why are we considering Flight is assigned to Aircraft.

The assumption for the below question: Flight is not an Aircraft
Aircraft has the method getFlights and it says Flight class knows(calls) about Aircraft as per diagram. If Flight class knows about AirCraft, shouldn’t it be like get details of aircraft in Flight?

The flight is assigned to Airport:
How come flight only knows(calls) about Airport(Flight–>Airport)? We can get details of flights from the airport class also.

Crew vs Flight Instance
Flight instance will have Crew/Pilot details, but the diagram says Crew/Pilot know about Flight Instance. Shouldn’t it be a two-way association? In the initial basics, it is shown as the two-way association.
Thanks,
Surya

Hi Surya,

Thanks for posting the question.

Actually, it seems more appropriate to assign a FlightInstance (instead of a Flight) to an aircraft. Consider this relationship in the context of “Each flight instance will use one aircraft”. The analogy can’t be applied to book --> book item, as over there, book is an abstract class.

You suggestions are correct about Airport knowing about flights and Crew/Pilot knowing about Flight Instance. It should be two- way associations. Thanks for pointing these out.

Hope this clarifies your questions.

Thanks for your response.

Why there are no interfaces usage any of the designs except for search. Are we not supposed to use the concept of design patterns and interfaces in object design.

Thanks,
Surya

1 Like

Hello @Design_Gurus ! I am a little confused about the uni-directional relationship between flight and aircraft in the diagram. What does it mean that Flight knows about Aircraft but Aircraft doesn’t know about Flight? I was thinking if that were the case, shouldn’t flight have an instance variable called Aircraft?

Your help would be greatly appreciated!
Thank you,