Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Association or Not

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frank, well said!
 
kyyung6
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic