This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Explain Association and other terms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Explain Association and other terms" Watch "Explain Association and other terms" New topic
Author

Explain Association and other terms

Ra Sank
Greenhorn

Joined: Jun 02, 2008
Posts: 14
Can any one tell me the subtle difference between association, aggregation, and composition?


Learning Java.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
Welcome to JavaRanch

I think Rob will probably want to move this thread to "beginners.2

I think you will have to look in Google . . .

But I found Aggregation and Object composition on Wikipedia. I think those two links eventually lead to the same page!

Both aggregation and composition can be described by a HAS-A relationship. Aggregation: a car HAS-A driver, but if you take the driver from the car the car is still a working car.
Composition: a car HAS-AN engine, but if you take the engine from the car the car is no longer a car in the fullest sense of the word; neither the car nor the engine will "work."

You mean "inheritance" not "association." That is described with an IS-A relation, and should also fulfil Barbara Liskov's substitution principle, which I haven't got time to describe. I couldn't find "inheritance" in wikipedia. You should find details in any object-oriented programming book, but composition is usually much easier to handle than inheritance.

"Association" is a compiler term; there is a bit about it in Wikipedia under the name Operator associativity.
[ June 02, 2008: Message edited by: Campbell Ritchie ]
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Campbell Ritchie:
"Association" is a compiler term


It has another connotation more appropriate to the original poster's question.

Association might be used as a word to describe "having a reference to an object, but not necessarily owning it". If a particular Java object has a reference to another Java object, but the first Java object is not responsible for managing the second, that might be described as "association".

I don't think there would be a formal definition anywhere for such a use of "association".


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19557
    
  16

Originally posted by Campbell Ritchie:
I think Rob will probably want to move this thread to "beginners.2

Well, if you insist...


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Explain Association and other terms
 
Similar Threads
Association
Association or Not
Hibernate POJOs -- association or no-association ?
Is that an association?
Place Association