plong
plong

Reputation: 1753

Resetting lifeline activations at beginning of each alternative

Assuming that sequence-diagram alternatives should be somewhat interchangeable, how does one deal with an alternative leaving lifelines with a different number of (possibly nested) activations than it encountered at the beginning? For example, here are sequence diagrams for a "ready" case, a "not-ready" case, and a failed attempt to combine those cases in a single sequence diagram using "alt". (Sorry about the diagrams--I couldn't figure out how to top align them.)

ready casenot-ready casecombined cases

Looking at the last, "combined cases" diagram, 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 surely there is a better way, or am I missing something, e.g., I'm using alt incorrectly?

BTW, I generated these diagrams with PlantUML.

Upvotes: 2

Views: 2130

Answers (3)

plong
plong

Reputation: 1753

I thought about it some more and came to this conclusion. I won't consider marking this as the best answer until others have had a chance to respond.

Two axioms of alternative fragments are 1. all alternatives are presented with the same set of activations, α, upon entry and 2. all alternatives end with the same set of activations, β. The problem with UML Sequence Diagram notation, IMO, is that it has a separate, non-axiomatic requirement that each alternative ends with the same set of activations with which it was presented, or α = β.

Upvotes: 1

qwerty_so
qwerty_so

Reputation: 36305

I would just use two separate SDs named ready case and not-ready case. You should not try to implement graphical programming with SDs. If you can transport a message with your diagrams in an easy way then take that road. As so often Occam applies.

Upvotes: 1

radscheit
radscheit

Reputation: 352

You can use sequence diagrams in this way but be careful: When a lifeline is active while entering the alt fragment it should be active on leaving the fragment to. And when it is not active no entering then it shouldn't be on leaving.

In your combined cases diagram is a problem with that regarding the lifeline of C. I suggest that every other action regarding C that you planned maybe for it after the fragment should be part of the [ready case]. Otherwise the diagram gets inconsistent from my perspective.

Upvotes: 1

Related Questions