用例与用例场景

问题描述 投票:0回答:1

我需要指定删除 2 种类型的对象 x 和 y 的用例,其中 y 是对象 x 的列表。

我想避免用例过度碎片化,因为两个用例之间的事件流是相似的。 我应该指定 2 个用例,

Delete x
Delete y
,还是单个用例
Delete object
,其中包含删除 x 的主要场景和删除 y 的替代场景?或者有更好的解决方案?更一般地说,对于类似的情况,例如共享对象 x 和对象 y,推荐的方法是什么以及何时使用替代方案?

这就是我对第一个选项的意思:

用例删除x

Pre-conditions: Authentication
Post-Condition: The object x is deleted
Main scenario:
1.The actor starts the use case
2.The system shows the list of objects x
3.The actor selects the object x to delete
4.The system deletes the object x

用例删除 y

Pre-conditions: Authentication
Post-Condition: The object y is deleted
Main scenario:
1.The actor starts the use case
2.The system shows the list of objects y
3.The actor selects the object y to delete
4.The system deletes the object y

还有第二个选项

用例删除对象

Pre-conditions: Authentication
Post-Condition: The object is deleted
Main scenario:
1.The actor starts the use case
2.The system asks to the actor if he want to delete object x or object y
3.The actor makes his choice
4.The system shows the list of objects x
5.The actor selects the object x to delete
6.The system deletes the object x

3.a
  1. activate the scenario "Object y"

Alternative scenario #1 - Object y
1.The system shows the list of objects y
2.The actor selects the object y to delete
3.The system deletes the object y
uml use-case scenarios use-case-diagram
1个回答
0
投票

您应该根据用户目标识别相关用例,而不是根据用户界面或系统的内部结构。

考虑您的解释,并假设您需要在该详细程度上工作:

  • 如果参与者可能主要想要删除对象 x 或 y,独立地,那么拥有单独的用例可能是有意义的。
  • 如果这些对象的删除是不是独立的,例如,如果 y 是一个照片相册,并且 x 其中的照片,那么您将只有一个用于删除相册的用例,并且该用例的一个方面是是否需要删除不同的照片,或者是否需要将某些照片移动到另一个相册。那么最好有一个用例具有替代场景。

但是,您的示例表明您可能还有其他 CRUD 用例。如果您不想以大量案例和场景结束,则有更好的 CRUD 方法:利用专业化(继承):编写一个通用场景,并为参与者想要删除的对象提供占位符。在这种情况下,您不需要额外的场景或额外的用例,除非一个或其他对象需要不同的行为,在这种情况下,您最好不要重复自己并将特殊情况记录为替代场景。

这些问题中的更多信息:

顺便说一句:恭喜您通过了身份验证!

© www.soinside.com 2019 - 2024. All rights reserved.