什么时候应该在 UML 图中使用依赖关键字 <<use>>?

When should I use the dependency keyword <<use>> in UML diagram?

参考this source,UML的定义是

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.

但是,根据教科书,UML Distilled,在 Class 部分图表:要点 -> Dependency,关键字<<use>>被描述为

The source requires the target for its implementation.

在这里,我看不出一般的 dependency 行和特定的 <<use>> 关键字有什么区别。在任何情况下 <<use>> 是必要的还是多余的?

根据 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).

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.

所以主要区别在于仅用于依赖项的“规范”。基本上这意味着如果您只是在概念上需要其他一些 class 但实际上在 运行 期间不需要它,您也可以有依赖关系。 <<use>> 是更强的关系,需要对另一个 class 进行“物理”使用。我认为在超过 99% 的情况下,这都是正确的,你可以把 <<use>> 去掉。