• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

association, aggregation, Composition

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any one define and differentiate between association, aggregation, Composition with an example ?
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not an example, but this page may help: AssociationVsAggregationVsComposition
 
sita raman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks.But i had alrsdy gone through this link.still am not clear about the concept.please advice
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you try to describe those concepts in your own words, and others can jump in and help if you feel you're on shaky ground.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you asking for a code exmaple here?

Then the problem is that there are many ways to implement them, and the code doesn't even necessarily look differently. The difference between the three concepts is much more in the intention than in the structure of the code.
 
sita raman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please advice whether my concept is correct.

Association is similar to the HAS relationaship.ie one class have the reference of the other.

Class A{
B b;
}

Aggregation is the collection of reference.

Class A{
Vector v1;//contains the collection of reference A.
}

Composition is one which cretes and detroy the othe rererence.

Class A{
B a=new B();
}
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, every single of those examples could be either Composition, Aggregation or simple Association. (Although the probability for the last to be Composition might be a bit higher.)

It really depends on what the code that you haven't shown does with the object, and *why*.
 
See where your hand is? Not there. It's next to this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic