Scribble.orgCommunity Documentation
This section discusses some common interaction based design patterns.
There are two ways to represent a while loop being terminated by an interaction.
Many interactions occur between participants where a set of repeating messages will occur until some condition is met. Usually, the party that is sending the initial message within the loop will be the one to decide whether or not to continue iterating around the loop, or to break out of the loop and continue with the next activity.
If the activity (or activities) following the while loop are also interactions from the same party, then it is possible for the receiving party to determine if the loop has iterated again, or finished, based on which message it receives from the sending party. This is know as using a lookahead message to determine which path to take.
Therefore in this situation, the sending party can optionally define an expression within the while loop, to determine whether to iterate around the loop (although it can use a non-observable expression). However the receiving party should not define an expression (i.e. it should be non-observable), to enable the path to be determined based on the observed action taken by the sending party.
TODO: Include image of while loop with interaction inside and after loop - possibly with a choice of interactions at the end
Many interactions occur between participants where a set of repeating messages will occur until some condition is met. Usually, the party that is sending the initial message within the loop will be the one to decide whether or not to continue iterating around the loop, or to break out of the loop and continue with the next activity.
If the interaction (or interactions) that will cause the while loop to terminate are not interactions from the same party that sends the initial interaction within the loop, then it will not be possible to define these break-out interactions outside of the while loop and use the lookahead approach to break out of the loop (as described above).
Instead, it will be necessary to include the terminating interaction(s) inside the while loop as an alternate choice path from other activities that occur within the while loop. If these alternate paths are taken, then a control flag can be set (at both parties) to indicate that a terminating interaction has occurred. When the while loop expression is subsequently evaluated at both parties, then the while loop will terminate.
TODO: Images of a choreography demonstrating the above scenario.