在用例图中包含和扩展之间的区别是什么?


当前回答

当您理解您的用例过于复杂时,可以使用Extends。因此,您将复杂的步骤提取到它们自己的“扩展”用例中。

Includes用于在两个用例中看到相同的行为。因此,您将常见的行为抽象到一个单独的“抽象”用例中。

(参考:Jeffrey L. Whitten, Lonnie D. Bentley,系统分析与设计方法,McGraw-Hill/Irwin, 2007)

其他回答

还要注意UML版本:现在<<使用>>和<<包含>>已经很长时间了,已经被<<包括>>所取代,<<扩展>>由<<扩展>>和泛化。 对我来说,这往往是误导性的观点:例如Stephanie的帖子和链接是关于一个旧版本的:

在付款时,您可以选择货到付款、使用paypal付款或刷卡付款。这些都是“为物品付费”用例的替代方案。我可以根据自己的喜好选择其中任何一种。

事实上,除了“为物品付费”,没有其他选择!在现在的UML中,“货到付款”是一个扩展,“使用paypal支付”/“刷卡支付”是专门化的。

图元素

Actors: Also referred to as Roles. Name and stereotype of an actor can be changed in its Properties tab. Inheritance: Refinement relations between actors. This relation can carry a name and a stereotype. Use cases: These can have Extension Points. Extension Points: This defines a location where an extension can be added. Associations: Between roles and use cases. It is useful to give associations speaking names. Dependencies: Between use cases. Dependencies often have a stereotype to better define the role of the dependency. To select a stereotype, select the dependency from the diagram or the Navigation pane, then change the stereotype in the Properties tab. There are two special kinds of dependencies: <<extend>> and <<include>>, for which Poseidon offers own buttons (see below). Extend relationship: A uni-directional relationship between two use cases. An extend relationship between use case B and use case A means that the behavior of B can be included in A. Include relationship: A uni-directional relationship between two use cases. Such a relationship between use cases A and B means, that the behavior of B is always included in A. System border: The system border is actually not implemented as model element in Poseidon for UML. You can simply draw a rectangle, send it to the background and use it as system border by putting all corresponding use cases inside the rectangle.

我不建议用这个来记住这两点:

我的用例:我要去城市。

包括->驾驶汽车

Extends ->填充汽油

我宁愿你用: 我的用例:我要去城市。

Extends ->驾驶汽车

包括->加油

扩展关系延续了基类的行为。基类功能必须在那里。 另一方面,包含关系类似于可能被调用的函数。梅是粗体字。

这可以从 用例模型中的重用

这里已经解释了两者之间的区别。但没有解释的是,<<include>>和<<extend>>根本不应该被使用。

如果你读过Bittner/Spence,你就知道用例是关于综合的,而不是分析的。用例的重用是毫无意义的。它清楚地表明您已经错误地切割了您的域名。附加值本身必须是唯一的。我所知道的唯一附加值再利用方式就是特许经营。如果你是做汉堡生意的,很好。但在其他任何地方,你作为BA的任务是试图找到一个USP。这必须在良好的用例中呈现。

每当我看到人们使用其中一种关系时,都是在尝试进行功能分解的时候。这是完全错误的。

简单地说:如果你可以毫不犹豫地回答你的老板“我做了……”,那么“……”就是你的用例,因为你这样做得到了钱。(这也清楚地表明“登录”根本不是一个用例。)

在这方面,找到包含或扩展其他用例的独立用例是非常不可能的。最终,您可以使用<<extend>>来显示您的系统的可选性,即一些许可模式,它允许包含某些许可的用例或省略它们。但除此之外,就避免他们。

我认为msdn在这里解释的很容易理解。

包括[5]

包含用例调用或调用包含的用例。包含用于显示用例如何分解为更小的步骤。所包含的用例位于箭头末端。

扩展[6]

同时,扩展用例将目标和步骤添加到扩展用例中。延期只在特定条件下生效。扩展用例位于箭头末端。