• 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

Object relationships

 
Ranch Hand
Posts: 180
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am trying to get the exact defintion with examples for the Object relationships.

In OOPs all the Objects need to communicate with each other otherwise as said standing alone does not help, its a team game

I have 3 type of relations with me.I have found some disagreement on this.
Some people i have encountered they say Aggregation and Composition are special type of Association.Whereas other sphere of Intellegentsia go for the three are different.

I am somehow convinced by the later one.

Association:- When an Class A has connection to Class B by just having a reference to Class B.Where Class A's behaviour is not to create an Object of B type.That is assocaiton where it just associates with B.

Aggregatation:- In this case Class A has a behaviour (method) which created an instance of Class B i.e. Class A aggregates Class B.

Composition:- This relationship is when Class A fully controls the lifecycle of Class B. i.e. Class A creates Class B and Destroys Class B as its behaviour.

I would love to hear thoughts of experts here on this topic.

Saurav
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AssociationVsAggregationVsComposition
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may be a "grumpy old man" point of view, but how much does the distinction matter? I guess it really gets down to communication. We create diagrams with these decorations or a document with these words to communicate something. The state of understanding on these three terms is not good enough that I'd trust all readers will get the same information from it. I'd add a paragraph somewhere to clarify just what I mean by the terms and how it applies to this particular design.

The FAQ noted that this is less important in garbage collected languages like Java than others with explicit destructors. It is interesting that if you think you have composition where A controls the life cycle of B, and you let a reference to B slip out to other classes, A no longer controls the life cycle. Would composition on a design diagram make you think of keeping B completely private?
 
author
Posts: 608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In The Object Primer, www.ambysoft.com/books/theObjectPrimer.html I go into this issue in a bit of detail. Here are some thoughts:
1. It doesn't really matter in the long run. The real goal is to build high quality software which meets the actual needs of your stakeholders, not to produce pretty diagrams.
2. Composition is a stricter form of aggregation.
3. Aggregation is a stricter form of association.
4. It really doesn't matter in the short run. So, the real issue here is whether you need to include a diamond on one end of the association line, and if so whether or not it should be filled in?

- Scott
 
I'm still in control here. LOOK at this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic