Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+35 votes
asked in CSC285_Fall2018 by (1 point)

1 Answer

+16 votes
 
Best answer

Short version: Aggregation and composition are both special types of "association". They both represent whole/part relationships, but composition is "stronger", in the sense that if you removed the whole, then all of the part objects should disappear as well.

If a Person class has two Hand objects that are part of it, that's presumably composition, since the Hands shouldn't exist without the person.

If a SoccerTeam object contains a bunch of Player objects, then that could be aggregation, since a team is made up of players, but those individual players could still exist (e.g. maybe join other teams) even if the SoccerTeam gets disbanded.

Longer version: https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-aggregation-vs-composition/

Note: I won't expect you to make this subtle distinction on the exam.

answered by (508 points)
selected by
...