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


当前回答

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

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

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

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

其他回答

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

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

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

图元素

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 ->驾驶汽车

包括->加油

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

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

我经常用这个来记住这两点:

我的用例:我要去城市。

包括->驾驶汽车

Extends ->填充汽油

“加油”不一定总是被要求,但也可以根据车里剩余的汽油量来选择。“开车”是一个先决条件,所以我把它包括在内。

当一个用例有先决条件时,就使用include。

对于有身份验证的用例,最坏的情况,或者是可选的,然后选择extend..

示例:用于寻求入场、预约、机票预订的用例 您必须填写一份表格(注册或反馈表)....这就是包容的由来。

例如:对于验证登录或登录您的帐户的用例,您的身份验证是必须的。还要考虑最坏的情况。比如按时还书,没有预定,逾期付款,这就是延期发挥作用的地方。

不要在图中过度使用include和extend。

保持简单,傻瓜!!