Search code examples
umldirectionsequence-diagramplantuml

PlantUML create in a different direction


is there a way to control where in a plantUML sequence diagram an object is created? Have a look at this simple example. Here I would like to have the GUI between the Console and the user.

enter image description here

The Code for this diagram looks like this:

 /*
 * 
 * @startuml
 * skinparam sequenceParticipant underline
 * 
 * actor User
 * participant "Console" 
 * database "DB"
 * activate User
 * 
 * User -> Console : giveMeGUI()
 * activate Console
 * create GUI
 * Console -> GUI
 * GUI -> User : Hi there 
 * @enduml
 */

Thank you for your help


Solution

  • While it is not in the UML specifications, the convention for ordering lifelines is generally depicted in the order in which they are first used and/or created. Having GUI appear before Console would at a moment's glance indicate that it is created/used before Console, though closer inspection would show that it is created by Console.

    Is it maybe that you don't like the GUI response crossing over Console's execution specification. If so, unless giveMeGUI()'s execution persist beyond GUI creation, it should be deactivated anyways.

    For example

    @startuml
    skinparam sequenceParticipant underline
    
    actor User
    participant "Console" 
    activate User
    
    User -> Console : giveMeGUI()
    activate Console
    create GUI
    Console -> GUI : <<create>>
    deactivate Console
    activate GUI
    GUI -> User : Hi there 
    deactivate GUI
    database "DB"
    @enduml
    

    would result in the following

    enter image description here