用例图:何时分解用例,何时不分解?

huangapple go评论55阅读模式
英文:

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, and pure 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.
  • 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 and Confirm 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 of Buy a kind of drink. For Buy carbonated and Buy tea, should I keep the including use-cases: Choose brand and Choose 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 drinkand 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.

huangapple
  • 本文由 发表于 2023年8月9日 11:21:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76864351.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定