UML Activity Diagram Loop

The loop in the activity or algorithm can be depicted in various ways using a UML Activity Diagram.

Loop Node

You can model the loop using the UML Loop Node. The Loop node consists of 3 partitions (activity regions) that contain various parts of the loop:

  • setup - defines the initial conditions of the loop
  • test - defines the condition when the loop can continue. The output value of the activity defined in this partition must be true to continue. If it is false, the flow continues with the next node after the Loop node.
  • body - defines the activity that will be executed when the test condition is fulfilled.
Loop in UML Activity Diagram
Loop in UML Activity Diagram

The example diagram shows a simple loop that iterates from 1 to 10 and repeats an action called 'Do action'.

Simple Flow and Decision Node

The loop can also be depicted using a simple flow with actions and a decision node.

Loop in UML Activity Diagram (Alternative Version)
Loop in UML Activity Diagram (Alternative Version)

New Comment

Comment