英文:
Use-case diagram: When to decompose use-case and when not to?
问题
举个例子,假设我想为一个人工售货机绘制一个用例图,如下所示:
-
售货机有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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论