avi10000
avi10000

Reputation: 343

UML activity diagrams: the meaning of <<iterative >>

I want to check what is the definition of «iterative» in expansion regions in activity diagrams. For me personally this was never a question because I understand it as letting me do a For loop, e.g.,

For i=1 to 10 
  Do-Something // So it does it 10 times 
End For 

However, while I was presenting my UML diagram to an audience, an engineer team leader (not a UML maven) objected against the term ‘iterative’, because he understood ‘iterative’ to mean an 'iterative process' such that each step improves a result. I am also aware of this definition, but I assume the UML definition is not that, but rather means a simple For-Loop.

Please confirm that the UML definition of «iterative» and iteration is like a simple For-loop. Or otherwise, if so.

Upvotes: 4

Views: 492

Answers (2)

Ister
Ister

Reputation: 6318

Ahhh, semantics...

First a disclaimer - I am not a native English speaker. Yet my believe both my level of English and IT experience are sufficient to answer this question.

Let's have a look at the dictionary definition of iterative first:

iterative adjective

/ˈɪtərətɪv/
/ˈɪtəreɪtɪv/, /ˈɪtərətɪv/

​(of a process) that involves repeating a process or set of instructions again and again, each time applying it to the result of the previous stage

  • We used an iterative process of refinement and modification.
  • an iterative procedure/method/approach

The highlight with a script font is mine.

Of course this is a pure word definition, not in the context of software development.

In real life a process can quite easily be considered repetitive but in itself not really iterative. Imagine an assembly line in a mass production factory. On one of the positions a particular screw/set of screws is applied to join two or more elements. For every next run, identical set of elements the same type and number of screws is applied. There is a virtually endless stream of similar part sets, each set consisting of the same type of parts as previously and requiring the same kind of connection. From the position perspective joining the elements is a repetitive process but it is not iterative, as each join is applied to a different set of elements - it does not apply to those already joined.

If you think of a code, it's somewhat different though. When applying a loop, almost always you have some sort of a resulting set impacted by it and one can argue that with every loop step that resulting set is being further changed, meaning the next loop step is applied on the result of the previous step. From this perspective almost every loop is iterative.

On the other hand, you can have a loop like that:

loop
  wait 10
while buffer is empty
 
read buffer

You can clearly say it is a loop and nothing is being changed. All the code does is waiting for a buffer to fill. So it is not iterative.

For UML specifically though the precise meaning is included in qwerty_so's answer so I will not repeat it here.

Upvotes: 1

qwerty_so
qwerty_so

Reputation: 36313

No, it has a different meaning. UML 2.5 states in p. 480:

The mode of an ExpansionRegion controls how its expansion executions proceed.

  • If the value is iterative, the expansion executions must occur in an iterative sequence, with one completing before another can begin. The first expansion execution begins immediately when the ExpansionRegion starts executing, with subsequent executions starting when the previous execution is completed. If the input collections are ordered, then the expansion executions are sequenced in the order induced by the input collection. Otherwise, the order of the expansion executions is not defined.

Other values for this keyword are parallel and stream. You can guess that behavior defined in a parallel region can be executed in parallel. stream is a bit more complicated and you might read on that page in the UML spec.

The for-loop itself comes from the input collection you pass to the region. This can be processed in either of the above ways.

tl;dr

So rather than a for loop the keyword «iterative» for the region tells that it's behavior may not be handeled in parallel.

Upvotes: 2

Related Questions