tronski
tronski

Reputation: 90

Do UML sequencediagrams have a convention for the forEach construct

I need to create a sequence diagram for a project I am currently working on. The sequence in question does contain a forEach loop, which does some action for every available user.

Is there any consensus/ convention on how to translate a forEach-loop to a loop-fragment? I personally used "for each user in users" as condition for the loop fragment.

Upvotes: 3

Views: 268

Answers (1)

qwerty_so
qwerty_so

Reputation: 36313

Not specifically. A loop fragment just has a guard to describe the loop condition.

enter image description here

These constraints somehow glitch over into the coding world. C guys are familiar with for (<init>; <cond>; <inc>) constructs so you could simply place

[<init>; <cond>; <inc>]

as the guard. Similarly you can place a foreach.

Note that this might go into details which in SDs are not foreseen. Sort of graphical programming. SDs are here to give an overview of collaborating classes, not as detailed coding templates. Probably a foreach is acceptable, though.

Upvotes: 3

Related Questions