-
Key: UML241-40
-
Legacy Issue Number: 7617
-
Status: open
-
Source: Simula Research Laboratory ( Dr. Bran Selic)
-
Summary:
This issue is submitted on behalf of Craig Larman (see signature at the end fo this e-mail):
Current: The LOOP keyword, used in sequence diagrams in a frame, has the syntax LOOP, LOOP( repeat ), or LOOP( min, max)
Problem: Iteration over a collection of objects, sending the same âdoXâ message to each member is a very very common idiom, so it would be nice if the UML had an easy notation to support this (and otherwise, how will you reverse engineer to code to the right diagram case, or vice versa? It is currently not clear ). AAt present, it is not clear how to say âfor i = 1 to collection.sizeâ, nor is there support to allow this âiâ loop variable to be reference in a lifeline *selector*
Solution:
1. change the LOOP syntax to (in its fullest form), LOOP( <varName>, <start>, <end>, <increment>) e.g., LOOP( i, 1, 10, 1), or LOOP( i, 10, 1, -1). Increment should default to +1.
a. Also <start> and <end> may be expressions referring to participants in the interaction, such as end = lineItems.size where lineItems is a collection of SalesLineItem objects. Note that there is already syntax for a âmaxâ (similar to <end>), and one aspect of this change is making (or ensuring) it can be an expression involving lifeline participants, not just a constant.2. allow a lifeline contained within the frame to have its selector refer to the LOOP var. e.g., â lineItems[ i ] : SalesLineItemâ to indicate selecting one SalesLineItem from the lineItems collection, given the current value of âiâ. Note that a selector such as âlineItem[ i ]â is already allowed in the spec (and there are examples in the spec). this request is for tying the âiâ variable to the LOOP construct.
Variant Solutions:
Perhaps the upper-bound can be handled in the LOOP guard instead. E.g., [ i < lineItems.size ]. However, in this case, i still need a way to indicate the incrementing of âiâ, and the ability to legally refer to âiâ in the selector âlineItems[ i ].i attach a picture to illustrate.
-
Reported: UML 1.4.2 — Tue, 3 Aug 2004 04:00 GMT
-
Updated: Sun, 8 Mar 2015 14:12 GMT
UML241 — UML 2 Super/Interactions/ LOOP construct specifications
- Key: UML241-40
- OMG Task Force: UML 2.4 BRM RTF