This is a quick basic question of uml. I have a call-to-self, which starts a a loop, that creates some objects. I am wondering if this call-to-self arrow should point inside or outside the loop. I have illustrated the differences here:
-
2There's something wrong with you self-call. It does not open a 2nd level. – qwerty_so Oct 24 '16 at 21:10
3 Answers
I don't know your tool, but the self call should look like this:
You can see that the loop is inside the self call.

- 35,448
- 8
- 62
- 86
-
-
In your example it looks like a recursive message contra mine, which is a self-call. What is the difference between the two? – Viktor Oct 25 '16 at 11:35
-
I found a decent answer to that question here: [link]http://stackoverflow.com/questions/11626473/self-messagenon-recursive-vs-self-recursive-message – Viktor Oct 25 '16 at 11:52
-
I would imagine that you have a recursion in mind: call a routine which does some loop and then returns. – qwerty_so Oct 25 '16 at 12:13
The self call triggering the loop should end outside the loop block.
Each time a loop is executed, its whole block has to be executed. For instance if your self call ends inside the loop block, at each loop iteration the first event should be receiving of a self call. That definitely is not what you want to do as this self call should be received only once (and then start a loop). Thus definitely it has to end outside the loop block.

- 5,958
- 17
- 26
Since it's not in the loop better place it outside the loop on the diagram. This looks better from both logical and visual perspectives. Better use block on the vertical line to show, for example, that both actions will be in the same transaction or use 2 views, for example one sequence diagram and one activity diagram.

- 1,402
- 12
- 22