How can lifeline activations be reset at beginning of each alternative?

0 votes
asked Sep 22, 2015 in To be sorted by plong (160 points)
Assuming that sequence-diagram alternatives should be somewhat interchangeable, how does one deal in PlantUML with an alternative leaving lifelines with a different number of nested activations than it encountered at the beginning? For example, here are two sequence diagrams for a "ready" case and a "not-ready" case.

@startuml
title ready case

activate A
A->>B: run
activate B

A->>B: ready
activate B
deactivate B
A->>C: run
activate C
C->>B: connect
activate B
B->B: is ready?
activate B
B-->B: yes
deactivate B
|||
@enduml

@startuml
title not-ready case

activate A
A->>B: run
activate B

A->>C: run
activate C
C->>B: connect
activate B
B->B: is ready?
activate B
B-->B: no
deactivate B
B->>C: terminate
deactivate B
destroy C
... long delay ...
A->>B: ready
activate B
deactivate B
@enduml
 

And here is a failed attempt to combine those cases in a single sequence diagram using "alt":

@startuml
title combined cases

activate A
A->>B: run
activate B

alt ready case

A->>B: ready
activate B
deactivate B
A->>C: run
activate C
C->>B: connect
activate B
B->B: is ready?
activate B
B-->B: yes
deactivate B
|||

else not-ready case

A->>C: run
activate C
C->>B: connect
activate B
B->B: is ready?
activate B
B-->B: no
deactivate B
B->>C: terminate
deactivate B
destroy C
... long delay ...
A->>B: ready
activate B
deactivate B

end

@enduml
 

Notice that the first, "ready case" alternative is presented with one activation each of A and B and none for C. However, because this alternative creates new activations for B and C, the second, "not-ready case" alternative is presented with a different set of activations. I could add various messages at the end of "ready case" to arbitrarilly leave it with the same activations it originally encountered, but is there a better way? Or am I missing something fundamental about UML sequence diagrams?

1 Answer

0 votes
answered Sep 24, 2015 by plong (160 points)

I think I answered my own question on stackoverflow.

...