如何在用例描述中显示“如果”条件?

时间:2018-07-22 15:54:10

标签: uml pseudocode use-case sequence-diagram

当我们在基本流程中编写用例表*(id,描述,参与者,前提条件,后置条件,基本流程,替代流程)*时,我们展示了参与者与系统之间交互的简单步骤。我想知道如何在用例基本流程中显示条件? AFAIK,基本流程包含针对用例的简单简单步骤。但是如果没有伪代码,我无法显示条件? UML用例描述的基本流程中是否允许使用伪代码?

以下顺序的步骤是什么? enter image description here

对于上图,应该是下表吗?

-------------------------------------------------------------
| ID            | UC01                                      |
-------------------------------------------------------------
| Description   | do something                              |
-------------------------------------------------------------
| Precondition  |  --                                       |
-------------------------------------------------------------
| Postcondition |  --                                       |
-------------------------------------------------------------
| Basic flow    |  1. actor requests system to do something |
|               |  2. if X = true                           |
|               |        2.1 system does step 1             |
|               |     else                                  |
|               |        2.3 system does step 2             |
|               |  3. system return results to actor        |
-------------------------------------------------------------
| Alternate flow|  --                                       |
-------------------------------------------------------------

2 个答案:

答案 0 :(得分:3)

在类似Visual Paradigm的工具中,您可以使用if / else和loop条件对事件流进行建模,并将步骤指定为用户输入和系统响应。 enter image description here

答案 1 :(得分:2)

  • 使用备用流和异常流来记录这种行为。
  • do somethingstep 1显然是不同级别的,最好将它们放在单独的用例中。
  • Actor并不是演员角色的最好称呼,可以说它是User
  • 我必须将Step 1更改为Calculation 1以避免混淆。

示例

------------------------------------------------------------------------
| ID               | UC01                                              |
------------------------------------------------------------------------
| Level            | User goal, black box                              |
------------------------------------------------------------------------
| Basic flow       |  1. User requests Robot System to do something.   |
|                  |  2. Robot System performs UC02.                   |
|                  |  3. Robot System return results to User.          |
------------------------------------------------------------------------


------------------------------------------------------------------------
| ID               | UC02                                              |
------------------------------------------------------------------------
| Level            | SubFunction, white box                            |
------------------------------------------------------------------------
| Basic flow       |  1. Robot System validates that X is true.        |
|                  |  2. Robot System does Calculation 1.              |
------------------------------------------------------------------------
| Alternate flow 1 |  Trigger: Validation fails at step 1, X is false. |
|                  |  2a. Robot System does Calculation 2.             |
------------------------------------------------------------------------