Get your CodeRanch badge!*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Association or Not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Association or Not" Watch "Association or Not" New topic
Author

Association or Not

kyyung6
Greenhorn

Joined: Jan 17, 2002
Posts: 5
Hi
I have a question about the association of classes in class diagram. For example, I have classes called Customer and Order. Order does not have a reference of its Customer, it only stores the CustomerID of its Customer. I think it is not correct to show the association between these two classes in the implementation class diagram. Am I right?
Thank you
Leo
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
Well, said like that, the answer is no.
But you have to be careful and check your design.
Somewhere Order may depend depend on Customer, for example to get its address. If you have:

then you will have an association with a "local" stereotype (or a dependency relation. It depends which UML guru you are affiliated to ).

W.
[ October 11, 2002: Message edited by: Wilfried LAURENT ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
You could also invent your own stereotype for the association, indicating that it is done by an id instead of a reference (<<by id>> ) . You could even use a custom icon for this, which might be more communicative (a square with "id" inscribed, for example; used similar to the aggregation and composition icons).
Remember, the goal of UML is communication. It isn't tabooed to be creative!
[ October 11, 2002: Message edited by: Ilja Preuss ]

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
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
If all (or most) object-object relationships in your system are done using such IDs then it's an association, plain and simple.
The value in showing such an association in a UML diagram is that it helps a reader understand the relationships between objects. In many cases tha actual mechanism (id, reference, pointer, URL, XPath, whatever ...) by which one object refers to another is of lesser importance.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Frank, well said!
kyyung6
Greenhorn

Joined: Jan 17, 2002
Posts: 5
Thank you very much! All the answers are very helpful for me.
Leo
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269

Franck said:
The value in showing such an association in a UML diagram is that it helps a reader understand the relationships between objects

Sure! But the notations used have to be shared or explained somewhere.
I recently worked with somebody which had a stereotype for human and non-human (which had a black strip on the eye ) actors. Even if it did affect the bulk understanding of the diagram, I couldn't help asking myself why some actors had this black strip....
W.
[ October 11, 2002: Message edited by: Wilfried LAURENT ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Association or Not
 
Similar Threads
Cade's Class Example use of Association
Rational Rose - Direction of Association Name
Class Diagram -Association & Inheritance
Dependency vs. association ?
Difference between aggregation, association and composition