Book a Demo
Prev Next

Loop Node

A Loop Structured Activity Node is used for defining a loop, and is commonly associated with ‘While’, ‘Repeat’ or ‘For’ loop statements.

Each Loop Node has three partitions:

  • Setup commonly initiates variables to be used in the loop's exit-condition; it is executed once on entry to the loop
  • Test defines the loop exit-condition
  • Body can contain Actions to be executed repeatedly until the Test produces a false value

The results of the final execution of the Test or Body are available after execution of the Loop is complete.

Create a Loop Node

A Loop Node is depicted on an Activity diagram in this way:

A UML Loop Node showing Setup, Test and Body regions.

You define the Loop nodes by dragging Action elements from the Diagram Toolbox page into the 'Setup', 'Test' and 'Body' partitions. The 'Body' partition can contain several Actions, which can be linked and organized into the required structure. The elements are aligned on the top left of the partition, so that resizing the node maintains the organization of the structure within and between the partitions. If you try to shrink the node below the structure size, the node automatically defaults to the 'best fit' size.

An example UML Activity diagram featuring a Loop Node as modeled in Sparx Systems Enterprise Architect.



See also


From the Activity page of the Diagram Toolbox, drag a Structured Activity icon onto the Activity diagram.

A short menu displays.


Select the 'Loop Node' option.

The Loop Node displays on the diagram, with the element 'Properties' dialog (if the dialog does not display, double-click on the element).


Complete as many of the common element Properties fields as required, then close the 'Properties' dialog.


Display the Properties window ('Start > Application > Design > Properties') for the Loop Node, and click on the 'Loop' tab. Set these checkboxes as required:

  • 'Must Isolate' - defines concurrency: if selected, no object within the node can be used outside it; the objects are isolated from parallel use
  • 'Tested First' - defines the loop type; select for a For / While loop, deselect for a Repeat Until loop


For each of these fields, click on the Browse. or Add button as appropriate, to display the 'Select Pins' dialog and select an Action Pin:

  • Decider (an Output Pin within the 'Test' partition, the value of which is examined after execution of the Test to determine whether to execute the loop Body)
  • Loop Variable Input
  • Loop Variable
  • Body Output and
  • Result

The 'Select Pins' dialog lists only Input Pins for the 'Loop Variable Input' field and only Output Pins for the other fields.

If the required Action Pin does not already exist, you can click on the Add New button on the dialog to automatically create the Input pin or an Output pin for the node.


In the 'Nodes' panel, click on one of the 'Setup', 'Test' or 'Body' radio buttons to list the Actions and Activities contained in the corresponding partition of the Loop Node.

An element must be completely below the top edge of a partition to be listed for that partition - if it overlaps with the partition above in any way, it is treated as being part of that partition.


Click on the OK button to save the properties of the Loop Node.


Right-click on the Node in the diagram and select the 'Features | Interaction Points' option.

The Features window displays, showing the 'Interaction Points' tab.

Select the checkbox against each Interaction Point.

The Action pins should now be visible in the diagram, attached to the Node.

Manage Structural Elements


  • You can check on the exact location of an existing Action Pin by right-clicking on the pin name in the Loop Node's Properties window and selecting the 'Find in Project Browser' option; the location of the Action Pin in the Browser window is expanded and highlighted

OMG UML Specification:

The OMG Unified Modeling Language specification, (v2.5.1, p.479) states:

A LoopNode is a StructuredActivityNode that represents an iterative loop. A LoopNode consists of a setupPart, a test and a bodyPart, which identify subsets of the ExecutableNodes contained in the LoopNode. Any ExecutableNode in the LoopNode must be included in the setupPart, test or bodyPart for the LoopNode. When a LoopNode begins execution, any InitialNodes within it are immediately enabled. An ExecutableNode contained in the LoopNode, however, can only become enabled when the setupPart, test or bodyPart section that contains it is executed.

When a section is executed, any ExecutableNode in the section that has no mandatory input data and no incoming ControlFlow with a source in the same section is enabled and receives a single control token. Execution then proceeds according to the usual semantics of Activities, except that any offers made to an ExecutableNode in a section that is not executing are not immediately delivered but remain pending. The target ExecutableNode may accept any pending offers if it eventually executes as part of a later execution of the section that contains it.