Pattern 21 (Structured Loop)

FLASH animation of Structured Loop pattern

FLASH animation of Structured Loop (Pre-Test) pattern

FLASH animation of Structured Loop (Post-Test) pattern

Description

The ability to execute a task or sub-process repeatedly. The loop has either a pre-test or post-test condition associated with it that is either evaluated at the beginning or end of the loop to determine whether it should continue. The looping structure has a single entry and exit point.

Examples

While the machine still has fuel remaining, continue with the production process.

Only schedule flights if there is no storm task.

Continue processing photographs from the film until all of them have been printed.

Repeat the select player task until the entire team has been selected.

Motivation

There are two general forms of this pattern - the while loop which equates to the classic while...do pre-test loop construct used in programming languages and the repeat loop which equates to the repeat...until post-test loop construct.

The while loop allows for the repeated sequential execution of a specified task or a sub-process zero or more times providing a nominated condition evaluates to true. The pre-test condition is evaluated before the first iteration of the loop and is re-evaluated before each subsequent iteration. Once the pre-test condition evaluates to false, the thread of control passes to the task immediately following the loop.

The repeat loop allows for the execution of a task or sub-process one or more times, continuing with execution until a nominated condition evaluates to true. The post-test condition is evaluated after the first iteration of the loop and is re-evaluated after each subsequent iteration. Once the post-test condition evaluates to true, the thread of control passes to the task immediately following the loop.

Overview

As indicated above, there are two variants of this pattern: the while loop illustrated in Figure 31 and the repeat loop shown in Figure 32. In both cases, task B is executed repeatedly.

Figure 31: Structured loop pattern (while variant)

Figure 32: Structured loop pattern (repeat variant)

Context

There is one context condition associated with this pattern: only one instance of a loop can be active at any time, i.e. places p1 and p2 (and any other places in the body of the loop) must be safe.

Implementation

The main consideration in supporting the Structured Loop pattern is the availability of a construct within a modelling language to denote the repeated execution of a task or sub-process based on a specified condition. The evaluation of the condition to determine whether to continue (or cease) execution can occur either before or after the task (or sub-process) has been initiated.

WebSphere MQ provides support for post-tested loops through the use of exit conditions on block or process constructs. Similarly, FLOWer provides the sequential plan construct that allows a sequence of tasks to be repeated sequentially until a nominated condition is satisfied. iPlanet also supports post-tested loops through conditions on outgoing routers from a task that loop back to the beginning of the same task. BPEL directly supports pre-tested loops via the <while> construct. BPMN and XPDL allow both pre-tested and post-tested loops to be captured through the loop task construct. Similarly UML 2.0 ADs provide the LoopNode construct which has similar capabilities. SAP provides two loop constructs corresponding to the while loop and the repeat loop. (In fact the SAP loop construct is more general merging both the while and repeat loop into a single construct).

Issues

None identified.

Solutions

N/A.

Evaluation Criteria

Full support for this pattern is demonstrated by any offering which provides a construct which satisfies the description when used in a context satisfying the context assumption.

Product Evaluation

To achieve a + rating (direct support) or a +/- rating (partial support) the product should satisfy the corresponding evaluation criterion of the pattern. Otherwise a - rating (no support) is assigned.

Product/Language

Version

Score

Motivation

Staffware 10 - Not supported. Loops can only be created in the graphical editor.
Websphere MQ 3.4 + Post-tested loops are supported by the block construct.
FLOWer 3.51 + Iteration can be achieved through the use of the sequential plan construct
COSA 5.1 - There is no means of specifying repeated execution of an activity or set of activities.
iPlanet 3.0 + Supported thorugh the use of process variables in conjunction with routers.
SAP Workflow 4.6c + This pattern is supported through the loop construct. There are two types of loops: (1) the until loop and (2) the while loop. The until loop has a "body" that is first executed. After executing the body a Boolean condition is evaluated. If it evaluates to true, the process continues with the next step. Otherwise, the process the "loopback body" is executed and then the process is repeated from the beginning. The while loop is similar to the until loop, however, the "body" is always empty. Therefore, the "loopback body" is the only part inside the loop and this part is executed zero or more times.
FileNet 3.5 + Directly supported.
BPEL 1.1 + While loops are directly supported.
Websphere Integration Developer 6.0 + While loops are directly supported.
Oracle BPEL 10.1.2 + While loops are directly supported.
BPMN 1.0 + Both while and repeat loops are directly supported by activity looping.
XPDL 2.0 + Both while and repeat loops are supported for individual activities and sub-processes.
UML ADs 2.0 + Supported via the LoopNode construct.
EPC (implemented by ARIS toolset 6.2) - Not supported. There are only arbitrary cycles.
jBPM 3.1.4 - jBPM can achieve the behavior of structured loops, but any dedicated construct for this is missing.
OpenWFE 1.7.3 + OpenWFE provides direct support for the Structured Loop. Both the while-do and repeat-until variants of the Structured Loop pattern are supported by the <loop> construct. Furthermore, the <iterator> construct implements the behaviour commonly associated with for-loops from classical programming languages.
Enhydra Shark 2 - Enhydra Shark can achieve the behavior of structured loops, but any dedicated construct for this is missing.