How to represent a call being made in a loop in a sequence diagram?
I'm creating a sequence diagram, and one of the classes is being observed by another class. The observed class is calling update in the observer every 5 seconds in a loop. I need to show this in the sequence diagram. Is there a way to show it looping indefinitely out of sequence as it were?
Or does it not make sense in the context of a sequence diagram; should I not include it? Or should I include it in a different type of diagram?
Solution 1:
You can use a box enclosing the message send arrow (and whatever else is inside the same repetitive construct).
See this tutorial for an example.
link to larger image (archived)
Solution 2:
Just adding a clearer picture because this one at @joel.tony's answer is damn blur.
As you can see the loop happens inside the frame called loop n. There is a guard, array_size, which controls the loop's iterations.
In conclusion the sequence of the messages inside the loop n frame (those between DataControl
and DataSource
objects) will happen array_size times.