sequence diagrams, size of alt blocks

0 votes
asked Dec 19, 2018 in Question / help by puml-shepherd (120 points)

Hello Plantuml Experts,

I am about to document quite some procedures using sequence diagrams. It appears essential that within 'participants' some logic needs to be expressed.

Currently I am using 'alt'. Unfortunately the size of these alt blocks seems to be determined as well by all arrows within an 'alt' and its closing 'end' statement.

Since routines may have multiple calls to other participants and as well have more than one return statement my 'alt' blocks are printed much bigger than I'd like to see: they include all participants called from within the 'alt' and all callers being returned to from within the 'alt' block.

Unfortunately that makes the diagram unreadable. I now kind of adapt the logic I want to document just in order to get my diagrams, which is of course not what documentation should do.

Is there any way to control the horizontal size of such 'alt' blocks ?

Thanks in advance

participant B
participant C
participant D
note over C: some if-else logic in C should be horizontally limited to its scope: 'C'
note over B: the alt block visually includes B\nbut B is not part of the logic\n -> bad!
B -> C
alt this alt logic is coded exclusively in 'C'
note over C: but the logic appears all over B,C and D
B <- C : return variant 1
C --> D
D --> D
note right
this 'D' code as well appears
within the C's 'alt' block
but is not related to it
-> bad!
end note
C <-- D
B <- C : return variant 2
note over C: reason (my guess): the arrows between B,C and D
note over C: this simplified example still looks pretty\nnow think of e.g. 7 participants all calling each other\nconditioned by 'alt' conditions:\nall 'alt' blocks become 'global': what a mess !
note over C: How could I let those arrows *cross* the border\nof that 'alt' block instead of enlarging it ?
note over C: proposal: allow 'dashed' arrows to cross ...

1 Answer

0 votes
answered Dec 19, 2018 by Serge Wenger Work (15,620 points)


Form me the "alt" implementation is correct. It is an alternative in the sequence, not on one object or class. You could see a lot of sample like PlantUML, for example

commented Dec 20, 2018 by puml-shepherd (120 points)
Thanks for the reply. But correctness is not my issue.  Useful and intuitive documentation is.

Programming books and articles such as the linked one rarely present examples of a complexity where documentation gets its relevance just because of the complexity.

In complex documentations as well as in complex source code I'd like to see related artifacts show up as close as possible (as long as useful).
The (still simplified) example below renders all 'alt' statements as horizontally global. Vertically seen that is correct.
Seen as a 2-dimensional document such rendering appears more confusing to me than if logic ('alt' statements) was rendered close to those objects it actually belongs to.

I am not an expert in UML standards. And of course the current behaviour very likely is  quite useful for many use cases.  Just not for mine, unfortunately.


participant A
participant B
participant C
participant D
participant E
[-> A
alt ACond
A -> B
A -> E : Error
[<- A
alt BCond
B -> C
B -> E : Error
[<- B
alt CCond
C -> D
C -> E : Error
[<- C
alt DCond
D -> D
D -> E: Error
[<- D
D <- E
C <- D
B <- C
A <- B
[<- A