This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Association or Not

 
kyyung6
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank, well said!
 
kyyung6
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much! All the answers are very helpful for me.
Leo
 
Wilfried LAURENT
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic