英文:
Use-case diagram: When to decompose use-case and when not to?
问题
-
例如,假设我想为一个类似的人工自动售货机绘制用例图,如下所示:
-
自动售货机有3个选项:
碳酸饮料
、茶
和纯净水
。 -
用户只能选择上述其中一种进行订购:
- 如果用户选择
碳酸饮料
,则用户需要选择品牌,例如可口可乐或百事可乐。 - 否则,如果用户选择
茶
,则需要选择糖的数量。 - 或者如果用户选择
纯净水
,那就是全部了。
- 如果用户选择
-
在选择饮料之后,用户还必须选择饮料的数量(有点牵强)。然后,机器会发送确认消息供用户确认。
我尝试过这个,但不太确定,不知道要保留什么,要添加什么或删除什么。。
问题如下:
-
这里的“选择饮料数量”和“确认”应该作为独立的用例保留,还是应该与总体用例“购买一种饮料”合并?
-
如果至少要保留其中一个,它们应该被绘制为“购买一种饮料”的包含用例,还是应该绘制为独立的用例?
-
我考虑将3个用例“购买碳酸饮料”、“购买茶”、“购买纯净水”看作是“购买一种饮料”的离散化。对于“购买碳酸饮料”和“购买茶”,我是否应该保留包含用例:“选择品牌”和“选择糖的数量”,还是应该将它们删除?
-
更一般的问题:在什么情况下,执行某个大用例的步骤应该保留为用例,什么情况下不应该? 这里有很多类似的问题,但答案不一致。
英文:
For an example, say, I want to draw a use-case diagram for an artificial vending machine like so:
-
The vending machine have 3 options:
carbonated drinks
,tea
, andpure water
. -
The user can choose only 1 of the above for an order:
- If the user chooses
carbonated drinks
, the user needs to choose which brand: say Coke or Pepsi. - Else if the user chooses
tea
, then he/she have to choose the amount of sugar. - Else if the user chooses
pure water
, then that's it.
- If the user chooses
-
After choosing the drinks, the user then has to choose the number of drinks (a little bit contrived). The machine then sends out a confirmation message for the user to confirm.
I tried this but not really sure of it, don't know what to keep, what to add or what to remove..
The questions are:
-
Should the 2
Choose the number of drinks
andConfirm
here be kept independently as use-cases, or should they be merge with the grand use-case:Buy a kind of drink
? -
If at least 1 of them is to be kept, should I draw them as including use-case of
Buy a kind of drink
or should they be drawn as independent use-cases? -
The 3 use-cases
Buy carbonated
,Buy tea
,Buy pure water
I considered as the discretization ofBuy a kind of drink
. ForBuy carbonated
andBuy tea
, should I keep the including use-cases:Choose brand
andChoose sugar amount
or should I remove them also? -
More general question: When should a step of doing some big use-case should be kept as a use-case, and when shouldn't? There are a lot of questions on here that are the same, but the answers are non-consistent.
答案1
得分: 1
使用案例关注的是“是什么”,而不是“如何”。后者涉及到活动,并分为行动。用例只展示了一个正在考虑的系统为其参与者带来的附加值。
因此,唯一的附加值是“销售饮料”,仅此而已。
我建议阅读Bittner/Spence关于用例的内容。他们称之为“综合”,这是正确的词汇。不是分析,更不是分解。
奇怪的是,技术人员总是想要分解事物。嗯,我知道学习起来很困难,因为我也曾困惑不解。这可能是因为它涉及到简单性。
英文:
Use cases are about the what and not about the how. The latter goes into Activity and is split to Actions. Use case only show the added value a system under consideration brings to its actors.
So the only added value is Sell drink
and that's it.
I recommend reading Bittner/Spence about use cases. They call it synthesis and that's the right word. Not analysis and even less decomposition.
Strange, that techies always want to decompose things. Well, I know it's hard to learn since I had been scratching my head too. It's probably so complicated because its about simplicity.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论