Pregunta

I know that in UML, composition means that one class basically includes other with lifetime dependency,i.e. when this class is destroyed, the composing class is destroyed as well. Unlike the aggregation, the class is not shared. But then I saw - at system designers conference, this:

[A Plane]<>COMPOSITION---------[Passenger]0,1--------<>[Seat] 

This would mean that if the plane is destroyed, all passengers are destroyed (so far correct) BUT the passengers then were in aggregation (or association) relation to the seat, where each set can have 0 or 1 passenger. But in this case, isnt sharing of passengers? In reality with modern languages (C# e.g.), if just the Seat holds the reference to passenger, it will still exist, no matter that the Plane class was destroyed.

¿Fue útil?

Solución

A better expression of the relationships between these classes would be that seats (not passengers) are part of the composition of a plane, and passengers are associated with seats. Aggregation of passengers with seats would technically express a stronger relationship, but association seems to be the more natural (i.e. "real-world") relationship. When the plane is "destroyed", so are the seats, but the passengers "live on" and so do their associations with other parts of the model, such as a seat on another plane in another leg of the flight itinerary.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top