Search code examples
umlplantuml

plantuml: how to draw 2 sequence messages on same level?


I have some code like this:

class A
{
    void update()
    {
        update1();
        update2();
    }
}

and I'd like to draw it in plantuml.

I tried something like this:

@@startuml
autoactivate on
A -> A : update
A -> A : update1
return
A -> A : update2
return
@@enduml

then I got uml diagram like this:

plantuml

I don't like the dotted lines (return message). but if I remove the return message, the message levels (hierarchy) will be messed up. they are not on the same level any more.

@@startuml
autoactivate on
A -> A : update
A -> A : update1
A -> A : update2
@@enduml

is like this: update1 & update 2 not on same level

I want update1 and update2 to be on the same level.


Solution

  • Using autoactivate on the return are mandatory


    Doing :

    @@startuml
    A -> A : update
    activate A
    A -> A : update1
    activate A
    deactivate A
    A -> A : update2
    activate A
    deactivate A
    return
    @@enduml
    

    the result is :

    enter image description here

    or replacing the last return by deactivate :

    @@startuml
    A -> A : update
    activate A
    A -> A : update1
    activate A
    deactivate A
    A -> A : update2
    activate A
    deactivate A
    deactivate A
    @@enduml
    

    enter image description here


    Of course an other way is to use a UML modeler rather than a drawer