File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Association ,Composition, Aggregation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Association ,Composition, Aggregation" Watch "Association ,Composition, Aggregation" New topic

Association ,Composition, Aggregation

sarma kiran
Ranch Hand

Joined: Jul 17, 2008
Posts: 30
Can any one tell me the differece between composition, association and aggregation with some example.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Start here: AssociationVsAggregationVsComposition
Don Solomon
Ranch Hand

Joined: Jul 20, 2008
Posts: 48
Both Composition and Aggregation are Associations.
Composition IS-A Association.
Aggregation IS-A Association.

Composition is a strong association.
Aggregation is a weak association.

Composition indicates that the lifetime of an object is dependent on another object. Not so with Aggregation.

When the house is "destroyed", its composites (int-squarefeet, Floor-material) are also "destroyed". These are strong associations. The DriveWay still remains; this is a weak association.

Software development is an exercise in thinking not coding.
Nandakumar Rajamanickam

Joined: May 27, 2009
Posts: 5
Composition IS-A Association.
Aggregation IS-A Association.

it should be HAS-A instead of IS-A
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

sarma kiran wrote:Can any one tell me the differece between composition, association and aggregation with some example.

Both aggregation and composition are special kinds of associations. Aggregation is used to represent ownership or a whole/part relationship, and composition is used to represent an even stronger form of ownership. With composition, we get coincident lifetime of part with the whole. The composite object has sole responsibility for the disposition of its parts in terms of creation and destruction.

Moreover, the multiplicity of the aggregate end may not exceed one; i.e., it is unshared. An object may be part of only one composite at a time. If the composite is destroyed, it must either destroy all its parts or else give responsibility for them to some other object. A composite object can be designed with the knowledge that no other object will destroy its parts.

see compostion and aggregation
I agree. Here's the link:
subject: Association ,Composition, Aggregation
jQuery in Action, 3rd edition