Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WDESIGNER and version 23.2

Activity diagrams can also implement logic that is based on conditions. You can branch a control flow using the Decision element.

The following example shows an activity diagram that checks if a related REST service is up and running, or not.

Image Removed

The diagram performs a GET request on the service. Directly after this request, any thrown errors are caught and used to identify the status of the service.

how to use decisions in activity diagrams. The user can enter a positive number. The process will then return a message depending on if the number is smaller or greater than 10 and divisible by 4.

Anchor
decision_activity_diagram
decision_activity_diagram

Image Added

The branching conditions of the decision The branching conditions must evaluate to a Boolean value (boolean expression) and be defined on the outgoing control flows of the decision node as a Guard Expression. Page Logical Operators provides a list of all possible logical operators that can be used within a guard expression. You can also use Boolean operators (and, or) as described in Boolean Operators.

In the example above, there are two three outgoing control flows:

Nr.Control FlowConditionGuard Expression
1

Decision → setNotAvailable

REST service not availablecatch errorCode = "*" errorType = "*"

smallerTen

entered number smaller than tennumber<10
2

Decision → divisibleByFour

entered number divisible by fournumber.modulo(4)=0
3

Decision → greaterEqualTen

all other cases2

Decision → setReturn

REST service up and runningelse

The one or more of the control flows contain the actual condition(s) (1 and 2). Exactly one control flow must contain an else expression (23): This control flow is followed if all other expressions evaluate to false.

Info

The boolean operators of the xUML Runtime support short-circuiting. This means that the second operand is evaluated only when the result is not fully determined by the first operand.

Adding a Guard Expression

To add a guard expression to a control flow proceed as follows:

Select the control flow you want to add a guard expression to from the activity diagram and open the Attributes panel.

Image Modified

Enter a boolean expression into the field Guard Expression.

The entered expression is also displayed in a box next to the corresponding control flow in the diagram.

When the guard expression box is selected, you can move it any time.

Click the box and drag it to the desired position.

You can resize the guard expression box by clicking the square in the bottom right corner of the element and dragging it.

Specifying an Evaluation Order

The order attribute on the decision flow defines the order in which the guards should be evaluated.

To add an order to a control flow proceed as follows:

Image Added

Select the control flow you want to add an order to from the activity diagram and open the Attributes panel.

Image Added

Enter the order number you want to assign to the selected control flow.

Examples

The following tables shows some examples regarding the Designer example mentioned above:

ExampleEntered NumberGuard ExpressionConditionResult
17number<10(tick) entered number smaller than tenBranch 1 is followed without evaluating the other two branches
2
12

number<10

(error) entered number smaller than ten

Branch 2 is followed without evaluating the third branch

number.modulo(4)=0

(tick) entered number divisible by four

3
14

number<10

(error) entered number smaller than ten

Branch 3 is followed

number.modulo(4)=0

(error) entered number divisible by four

else

(tick)

Otp
Floatingfalse

Multiexcerpt include
SpaceWithExcerptINTERNAL
MultiExcerptNameActivity_Decision_Example
PageWithExcerptINTERNAL:_designer_examples

Rp

Children Display
depth1
pageModeling Activities

Rde