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:
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.
Step |
Action |
See also |
---|---|---|
1 |
From the Activity page of the Diagram Toolbox, drag a Structured Activity icon onto the Activity diagram. A short menu displays. |
|
2 |
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). |
|
3 |
Complete as many of the common element Properties fields as required, then close the 'Properties' dialog. |
|
4 |
Display the Properties window ('Start > Desktop > Design > Properties') for the Loop Node, and click on the 'Loop' tab. Set these checkboxes as required:
|
|
5 |
For each of these fields, click on the or as appropriate, to display the 'Select Pins' dialog and select an Action Pin:
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 on the dialog to automatically create the Input pin or an Output pin for the node. |
|
6 |
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. |
|
7 |
Click on the to save the properties of the Loop Node. |
|
8 |
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 |
Notes
- 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 UML specification (UML Superstructure Specification, v2.1.1, pp.384-385) states:
"A loop node is a structured activity node that represents a loop with setup, test, and body sections."
"Each section is a well-nested subregion of the activity whose nodes follow any predecessors of the loop and precede any successors of the loop. The test section may precede or follow the body section. The setup section is executed once on entry to the loop, and the test and body sections are executed repeatedly until the test produces a false value. The results of the final execution of the test or body are available after completion of execution of the loop."