"usecase" 图中用例之间的未知关联

Unknown association between usecases in "usecase" diagram

在一个项目中有一个用于同步文件的用例"sync"。当然有时 "sync" 用例需要 "downloading files" 这是另一个用例。所以"sync"和"downloading files"之间存在关联;但是 "downloading files" 不会 extend "sync",因为它是同步的一部分,有时没有同步就无法完成。虽然"sync"不会include"downloading files";因为有同步不需要做下载的情况。

如何在用例图中描述这种情况?

Use 可以在这种情况下使用 include

这是一个常见的误解,认为包含的用例必须总是被执行,而扩展用例是可选的

事实上,include 和 extend 之间的主要区别在于依赖性,而不是执行频率。

来自 UML 2.5 规范:

Include is a DirectedRelationship between two UseCases, indicating that the behavior of the included UseCase (the addition) is inserted into the behavior of the including UseCase (the includingCase).
[...]
The including UseCase may depend on the changes produced by executing the included UseCase. The included UseCase must be available for the behavior of the including UseCase to be completely described.
[...]
The Include relationship is intended to be used when there are common parts of the behavior of two or more UseCases. This common part is then extracted to a separate UseCase, to be included by all the base UseCases having this part in common. As the primary use of the Include relationship is for reuse of common parts, what is left in a base UseCase is usually not complete in itself but dependent on the included parts to be meaningful. This is reflected in the direction of the relationship, indicating that the base UseCase depends on the addition but not vice versa.

但要小心包含和扩展。在不知不觉中,您会将系统的每个功能描述为一个用例,这会违背其目的。

如果下载部分始终是sync的一部分(即只能从sync 但不是来自其他 UC 或作为独立 UC)然后 下载部分 sync 的一部分,因此 不应分解为单独的UC。它不会总是发生的事实不会改变这里的事情(它只是一个备用流程)。

如果下载部分是一个单独的 UC(即可以是 运行 独立的或者 - 仍然不鼓励将其分开 UC - 可以从其他 UC 调用)但它仅在 sync 的某些 运行 期间是 运行 然后它是 extend 类型的关系(箭头指向从下载部分同步)

如果下载部分是单独的UC(如上)但是每次sync是运行运行(即它是 sync 的每个流的一部分)然后它是 include 类型的关系(从 sync 指向的箭头 下载部分 ).

据我了解,它要么根本不是一个单独的 UC,要么是 extend。事实是:

because it is a part of synchronizing and sometimes synchronizing does not complete without that.

表明它不是单独的 UC(因此只需将其从图表中删除)。

然而如果它可以是一个单独的UC,那么在这部分:

Although "sync" does not include "downloading files";because there are situations that synchronizing does not need to do downloading.

你是对的 - 它不能 include 让你只剩下 extend 选项(这是正确的)。正如您所说,它是 sync 的一部分(这意味着它由 sync 触发并向其提供结果)这一事实正是需要它才能成为 extend.