• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BJO - Relationships b/w objects ??????

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jacquie,

I am little confuse between Dependencies, Association, Aggregation, Composition etc.

Aggregation is Has-a relationship.

Composition is strongest form of Aggregation.

Association is stronger form of Aggregation.

What is this all...

Could you please explain me these all with help of real example and code. Does BJO covers it??

Thanks a lot.
[ July 13, 2005: Message edited by: rathi ji ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See http://faq.javaranch.com/view?AssociationVsAggregationVsComposition
 
author
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's how I address that topic in BJO (paraphrasing):

===

An association is a relationship between two classes A and B, implemented in code as follows:

one-to-one -- we provide A with a reference to an object of type B as an attribute (and vice versa, if we want the association to be bi-directional)

one-to-many -- if there is one instance of A for many instances of B, we equip A with a Collection of references to B as an attribute

many-to-many -- both A and B wind up with a Collection of the other as an attribute (if bi-directional)

===

Aggregation -- essentially an association that implies containment -- e.g., "has a", "is part of", "belongs to", etc. Aggregations are represented in code identically to associations, as discussed above.

===

Composition -- a strong form of aggregation in which the "contained" object ceases to exist if the "containing" object ceases to exist. Again, coded in the same way that associations/aggregations are coded, but extra work must be done programmatically to make sure that the contained object is "snuffed" when the containing object is.

===

I hope this helps ...
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Jacquie,
It was very clear + short and sweet description .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic