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


当前回答

包含关系允许一个用例包含另一个用例的步骤。

例如,假设你有一个亚马逊账户,你想查看订单,如果不先登录你的账户,就不可能查看订单。所以事件的发展会这样。

扩展关系用于向用例流添加一个额外的步骤,这通常是一个可选的步骤…

假设我们还在谈论你的亚马逊账户。让我们假设基本用例是Order,扩展用例是Amazon Prime。用户可以选择定期订购商品,也可以选择亚马逊Prime,以确保他的订单以更高的成本更快到达。

但是,请注意,用户不必选择Amazon Prime,这只是一个选项,他们可以选择忽略这个用例。

其他回答

“包含”用于扩展基本用例,这是一个必须条件,即包含的用例运行必须成功运行以完成基本使用。

如。 考虑一个电子邮件服务的案例,这里“Login”是一个包含的用例,必须运行它来发送电子邮件(基本用例)

另一方面,“Exclude”是扩展基本用例的可选用例,基本用例即使不调用/调用扩展用例也可以成功运行。

如。 考虑“Laptop Purchase”作为基本用例,“Additional Warranty”作为扩展用例,在这里你可以运行基本用例“Laptop Purchase”,甚至不需要额外的保证。

这是一个很好的资源,有很好的解释: 用例中包含什么? 什么是扩展用例?

扩展用例通常定义可选的行为。它独立于扩展用例 Include用于提取两个或多个用例的行为的公共部分

图元素

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.

为了简化,

为包括

当基本用例执行时,包含的用例将每次执行一次。 基本用例需要完成所包含的用例才能完成。

一个典型的例子:在登录和验证密码之间

(登录)——<< include >>——>(验证密码)

为了使登录过程成功,“验证密码”也必须成功。


为扩展

当基本用例被执行时,扩展用例只是偶尔执行 扩展用例仅在满足某些条件时才会发生。

一个典型的例子:在登录和显示错误消息之间(只偶尔发生)

(登录 ) <--- << 扩展> >——(显示错误消息)

“show error message”只在登录过程失败时才会出现。

当用例向另一个一级用例添加步骤时,使用Extend。

例如,假设“提取现金”是自动柜员机(ATM)的一个用例。“评估费用”将扩展提现并描述有条件的“扩展点”,该“扩展点”在ATM用户不在ATM所属机构存入银行时实例化。注意,基本的“Withdraw Cash”用例独立存在,没有扩展。

Include用于提取在多个用例中重复的用例片段。被包含的用例不能独立存在,没有被包含的用例原始的用例是不完整的。这应该谨慎使用,并且只在重复很明显并且是故意存在(而不是巧合)的情况下使用。

例如,在每个ATM用例开始时发生的事件流(当用户放入他们的ATM卡,输入他们的PIN,并显示主菜单时)将是一个很好的包含候选。