在用例图中包含和扩展之间的区别是什么?
当前回答
包含关系允许一个用例包含另一个用例的步骤。
例如,假设你有一个亚马逊账户,你想查看订单,如果不先登录你的账户,就不可能查看订单。所以事件的发展会这样。
扩展关系用于向用例流添加一个额外的步骤,这通常是一个可选的步骤…
假设我们还在谈论你的亚马逊账户。让我们假设基本用例是Order,扩展用例是Amazon Prime。用户可以选择定期订购商品,也可以选择亚马逊Prime,以确保他的订单以更高的成本更快到达。
但是,请注意,用户不必选择Amazon Prime,这只是一个选项,他们可以选择忽略这个用例。
其他回答
<include>和<extend>都依赖于基类,但<extend>是可选的,也就是说,它是从基类派生的,但在用户的角度来看,它可以被使用,也可以不被使用。
<include>被合并到基类中,也就是说,在用例中必须使用<include>,否则它将被认为是不完整的。
eg:
在ATM机构造上(根据用户角度):
1:提现、存现、支票账户属于<extend>,因为它取决于用户是提现、存款还是支票。这些都是用户可以选择做的事情。
2:“输入pin,放置卡片,移除卡片”这些是在<包括>下的事情,因为用户必须,而且应该,放置卡片并输入有效的pin进行验证。
我认为理解includes和extends的意图很重要:
“包含关系旨在重用已建模的行为 通过另一个用例,而扩展关系是为 向现有的用例中添加部件,以及为可选的系统服务建模”(Overgaard和Palmkvist,用例:模式和蓝图。addison - wesley, 2004)。
在我看来,这是:
包含=功能的重用(即所包含的功能在系统的其他地方被使用或可能被使用)。因此Include表示对另一个用例的依赖。
Extends =添加(而不是重用)功能和任何可选功能。因此,Extends可以表示以下两种情况之一: 1. 向用例中添加新特性/功能(可选或非可选) 2. 任何可选的用例(是否存在)。
简介: 包含=功能的重用 Extends =新的和/或可选的功能
您将经常发现扩展的第二种用法(即可选功能),因为如果功能不是可选的,那么大多数情况下它被内置到用例本身,而不是作为一个扩展。至少这是我的经验。(Julian C指出,当项目进入第二阶段时,你有时会看到扩展的第一次使用(即添加新功能)。
图元素
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.
我记得是通过电子游戏。例如, (下面不是100%的用例,只是一个用例的例子)
扩展:主菜单扩展了一些功能,这意味着它们有一些功能,但不需要按下
包括:为了在电子游戏中开火,你必须先有一个武器。
我经常用这个来记住这两点:
我的用例:我要去城市。
包括->驾驶汽车
Extends ->填充汽油
“加油”不一定总是被要求,但也可以根据车里剩余的汽油量来选择。“开车”是一个先决条件,所以我把它包括在内。