How to represent a call being made in a loop in a sequence diagram?
Asked Answered
H

2

62

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?

Hiro answered 8/2, 2009 at 21:13 Comment(0)
P
68

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.

sequence diagram with loop link to larger image (archived)

Profession answered 8/2, 2009 at 21:51 Comment(3)
@sblundy I just clicked the link; it took my browser to the IBM developerWorks article on "UML basics: The sequence diagram" as intended.Profession
Although not entirely broken, when you get to the example in question and try to click for the larger image, then the link is brokenAdmeasure
A picture of just the component being described would be good. Or at the very least, highlighting it on the diagram given. Just that blurry (and busy) diagram by itself is unclear.Colorable
D
48

Just adding a clearer picture because this one at @joel.tony's answer is damn blur.

enter image description here

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.

Doehne answered 19/11, 2018 at 14:37 Comment(1)
This one is simple & better example.Leach

© 2022 - 2024 — McMap. All rights reserved.