File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes BJO - Relationships b/w objects  ?????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "BJO - Relationships b/w objects  ??????" Watch "BJO - Relationships b/w objects  ??????" New topic
Author

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

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
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 ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
See http://faq.javaranch.com/view?AssociationVsAggregationVsComposition


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jacquie Barker
author
Ranch Hand

Joined: Dec 20, 2000
Posts: 201
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 ...


Author of Beginning Java Objects, Beginning C# Objects, and Taming the Technology Tidal Wave
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Thanks a lot Jacquie,
It was very clear + short and sweet description .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BJO - Relationships b/w objects ??????
 
Similar Threads
Association /aggregation/composition
Association and dependency
Association ,Composition, Aggregation
BJO - Concepts to Best Code
What is a good example of association