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


@startuml
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
else
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
end
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 ...
@enduml


1 Answer

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

Dear,

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 https://www.ibm.com/developerworks/rational/library/3101.html

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.

==

@startuml
participant A
participant B
participant C
participant D
participant E
[-> A
alt ACond
A -> B
else
A -> E : Error
[<- A
end
alt BCond
B -> C
else
B -> E : Error
[<- B
end
alt CCond
C -> D
else
C -> E : Error
[<- C
end
alt DCond
D -> D
else
D -> E: Error
[<- D
end
D <- E
C <- D
B <- C
A <- B
[<- A
@enduml
...