Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is a good example of association

 
Mohanlal Karamchand
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as in <pre>
composition
/ \
/ \
/ \
/ \
/ \
aggregation association
</pre>
is it something as simple as
class A{}
class B{
public A a = new A();
}
or is it something deeper than that ?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A train.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(my appologies, I'm assuming this thread is going to be moved )
 
aadhi agathi
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mohanlal Karamchand:
as in <pre>
composition
/ \
/ \
/ \
/ \
/ \
aggregation association
</pre>
is it something as simple as
class A{}
class B{
public A a = new A();
}
or is it something deeper than that ?

association
/ \
/ \
/ \
/ \
/ \
aggregation composition
this seems more logical

also check out dependency( Class A calling a method of class B). Please check out the UML version 5. i like it except the word "semantic" [everthing is hiddedn under it]
 
Ellen Zhao
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My humble opinion, if the relationship between the two classes is not inheritance not aggregation not dependency, which are relatively easier to decide, then you may well relate the classes as association. For instance, traffic lights and cars, traffic lights conduct cars, association. Street traffic system aggregates both of the traffic lights class and cars class ( and many more ).
Does that make sense?

Regards,
Ellen
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to the OO forum, as this discussion is far too meaningful for MD.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mohanlal Karamchand:
as in <pre>
composition
/ \
/ \
/ \
/ \
/ \
aggregation association
</pre>

Sorry, I don't think I do understand this diagram...

is it something as simple as
class A{}
class B{
public A a = new A();
}
or is it something deeper than that ?

This may well be a valid implementation of an association relationship between B and A (it may also be an aggregation or even composition - it can't be decided from this code snippet).
The semantic of an association from B to A is that instances of B may send messages to (call methods of) instances of class A.
Notice that for this, B doesn't need to have a field of type A. This may change in UML 2.0.
 
Sahir Shibley
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he means that aggregation and association are two kinds of Composition.
Mr. Karamchand,
I noticed that this thread was moved here from MD.
What is the objective of this question ?
And why are you using a fake name in the OOP forum ?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sahir Shibley:
I think he means that aggregation and association are two kinds of Composition.

Then he is wrong - composition is a special kind of aggregation, which is a special kind of an association.
 
Sahir Shibley
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He seems to have been influenced by Kafura.
http://people.cs.vt.edu/~kafura/cs2704/aggregation.concept.html
Kafura goes on to say "An association among objects is created when an object contains references or pointers to other objects."
That statement seems to imply that association is a relationship between the class and it's public data member ???
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sahir Shibley:
He seems to have been influenced by Kafura.
http://people.cs.vt.edu/~kafura/cs2704/aggregation.concept.html

Uh oh - what a mess...
http://ootips.org/uml-hasa.html has it right, IMO.

Kafura goes on to say "An association among objects is created when an object contains references or pointers to other objects."

That's bogus - there are no associations between objects, only links (which are instances of associations). I think the reference above explains very well what an association is.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic