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


当前回答

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

包括[5]

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

扩展[6]

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

其他回答

<include>和<extend>都依赖于基类,但<extend>是可选的,也就是说,它是从基类派生的,但在用户的角度来看,它可以被使用,也可以不被使用。

<include>被合并到基类中,也就是说,在用例中必须使用<include>,否则它将被认为是不完整的。

eg:

在ATM机构造上(根据用户角度):

1:提现、存现、支票账户属于<extend>,因为它取决于用户是提现、存款还是支票。这些都是用户可以选择做的事情。

2:“输入pin,放置卡片,移除卡片”这些是在<包括>下的事情,因为用户必须,而且应该,放置卡片并输入有效的pin进行验证。

还要注意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.

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

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

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

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

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

包括[5]

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

扩展[6]

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