5

Referring to this source, the definition of UML is

Dependency is a directed relationship which is used to show that some UML element or a set of elements requires, needs or depends on other model elements for specification or implementation.

But then, according to the textbook, UML Distilled, in the section Class Diagram: The Essentials -> Dependency, the keyword <<use>> is described as

The source requires the target for its implementation.

Here, I can't see any difference between the general dependency line and the specific <<use>> keyword. Is there any case where the <<use>> is necessary or is it just redundant?

Kevin Winata
  • 443
  • 2
  • 10
  • It seems to me redundant too. I just write there semantic comments that are relevant to the meaning of the data represented by classes. I think there could be multiple valid approaches depending on the convention used. – Vojtěch Dohnal Nov 26 '18 at 09:19
  • Yes, It's true that it depends on the convention. But how about the formal UML used in _UML as blueprint_ referred in the UML Distilled book? Or are we not allowed to use generic dependency line only but rather always indicate the keywords (which then the keyword `<>` become helpful)? – Kevin Winata Nov 26 '18 at 09:27
  • Sorry, cannot help there, do not have the book. – Vojtěch Dohnal Nov 26 '18 at 09:50

1 Answers1

5

According to UML 2.5:

7.8.4 Dependency [Class]

7.8.4.1 Description

A Dependency is a Relationship that signifies that a single model Element or a set of model Elements requires other model Elements for their specification or implementation. This means that the complete semantics of the client Element(s) are either semantically or structurally dependent on the definition of the supplier Element(s).

and

7.8.23 Usage [Class]

7.8.23.1 Description

A Usage is a Dependency in which the client Element requires the supplier Element (or set of Elements) for its full implementation or operation.

So the main difference is found in "specification" which is only used for the Dependency. Basically that means you can have a dependency also if you just conceptually need some other class but actually do not need it during run time. The <<use>> is a stronger relation and demands a "physical" use of the other class. I think than in more than 99% of all cases this holds true and you can just leave the <<use>> away.

Community
  • 1
  • 1
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
  • Btw, could you give an example where it's found in spec but not needed in runtime? – Kevin Winata Nov 27 '18 at 14:01
  • You could think of the spec thing as "I got the idea from", something derived and evolved in a different direction. I don't have a concrete example, though. – qwerty_so Nov 27 '18 at 14:04