J.Y
J.Y

Reputation: 43

UML Sequence Diagram: Destroy an object with condition

I have a case that the application will destroy an object when condition is met. If the object is not destroyed, it will be used in later part in the sequence. I was wondering how to model that in sequence diagram.

Here is a simple demo, is that a valid sequence diagram?

enter image description here

Upvotes: 4

Views: 2098

Answers (1)

qwerty_so
qwerty_so

Reputation: 36323

You can not legally model it this way in UML

17.12.6 DestructionOccurrenceSpecification ... 17.12.6.4 Constraints

no_occurrence_specifications_below

No other OccurrenceSpecifications on a given Lifeline in an InteractionOperand may appear below a DestructionOccurrenceSpecification.

Which basically means that you can have the destruction occur only once. However, you can model the above like this:

enter image description here

Upvotes: 3

Related Questions