26

Case A Say you have 2 classes Model and Settings.

Settings contains nothing but public static constants used throughout the application. What type of relationship would you say these 2 classes have?

Case B Say you have a IntersectionManager singleton class that is being used by classes Road and Car to get some data out of it.

What is the name of "class uses class" relationship in UML?

Would you use the same relationships for both case A and case B? What UML arrow would you use to demonstrate this relationship?

James Raitsev
  • 92,517
  • 154
  • 335
  • 470

2 Answers2

38

Well, you could use the "uses" relationship (dotted or dashed line, open arrow). I found a nice and helpful overview at https://web.archive.org/web/20180722012752/http://usna86-techbits.blogspot.com/2012/11/uml-class-diagram-relationships.html

Baumflaum
  • 749
  • 7
  • 20
OBu
  • 4,977
  • 3
  • 29
  • 45
13

The regular black & solid association line in both cases. Optionally with arrows on either or both ends to illustrate the direction of usage.

Jarno Argillander
  • 5,885
  • 2
  • 31
  • 33
  • Depends on your implementation and who owns whom I guess. Maybe you're right but why ask if you know the answer already? – Jarno Argillander Nov 13 '11 at 23:12
  • I did not when the question was asked. Google was nice enough to assist. Can you add a bit more on "who owns whom" and how it matters please? – James Raitsev Nov 13 '11 at 23:16
  • It's usually really hard to put all distinct sides of class/object structure into one UML diagram such as ownerships, usages, class relationships, object relationships, object counts etc. – Jarno Argillander Nov 13 '11 at 23:17
  • fair enough :) Who owns whom means, which class has which other class as a member attribute. As a single attribute, array etc. Or it could also mean which object has which other object in a member attribute. – Jarno Argillander Nov 13 '11 at 23:22
  • Actually, now that I think more.. Both cases are about static classes being used from normal classes/objects (singleton object gained via static func call). Then the dependency type would sound more feasible. My hasty answer reflected my background as usually it takes too much time to try to make the perfect model. Thus I just use the regular association lines/arrows to model what I'm doing next and be done with it. As I said, UML fits poorly when trying to model everything in one diagram. You either end up frusturated or with plenty of diagrams about the same case from different angles. – Jarno Argillander Nov 13 '11 at 23:29