2

I'm working on a sequence diagram for a layered system that has a tree hierarchy. Now I have a process that works itself recursively down the tree. Meaning calling the same function on a child object.

I'm talking about a tree like this:

-layer n
   -layer n-1
       -layer n-2
           -...
       -layer n-2
           -...
   -layer n-1
       -layer n-2
           -...
       -layer n-2
           -...

Its easy to visualize a recursive process in the single object, but I could figure out how I would visualize recursive process that recursively calls itself on a lower layer object and so on. Is this even possible with an UML sequence diagram?

3
2

A sequence diagram doesn't represent a process, but a sequence of interaction between objects, where an object is a specific instance of a class.

Therefore, the representation of the recursion would be similar to the way you represent it in code: in one diagram you would only show what happen at one level of your recursion:

enter image description here

If there is no other object involved in the recursion, you would use a self-message.

2
  • Why are the execution specifications shifted to the right (left:node and right:node)? Is this a bug in the diagram or part of the notion of recursion? – Fuhrmanator Aug 22 '20 at 15:33
  • @Fuhrmanator No, this is a bug in the diagram. Perhaps related to the way I copied and resized it. – Christophe Aug 22 '20 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.