Association vs Aggregation vs Composition | Sololearn: Learn to code for FREE!

+1

Association vs Aggregation vs Composition

I've just started to learn Object Oriented Programming with Java . I could not understand what actually association is . Can you explain ? I found a very basic aggregation example like People need water in order to survive . People cannot survive without water . However water can exist without people . Is it valid ? Also for composition , I thought the birds . A bird have wings and a beak . Without wings or beak , a bird cannot be a bird . Also , without a bird , wings and beaks cannot be . For association , if I have a bird , then I think there will be association with a bird with me . Is it correct ?

3/3/2019 12:50:29 PM

Sevcan Doğramacı

1 Answer

New Answer

0

Yes these are correct. Association can be oneway or bidirectional. It depends on which object uses/knows about the other: bird is mine and the bird knows i'm his owner. Association can be on class level (association class for managing details of the relationship) and appears between objects itselves ( Dave owns Joe the parrot)