tsp
tsp

Reputation: 33

Q: How to handle more than one condition in a UML state machine transition

How do I handle more than one condition (with different boolean expressions) in a UML state machine transition (as guard)?

Example: enter image description here

In this example I would like to add more than only one condition (Tries < 3) in the transition from "logging in" to "Logged In" like discribed in the note.

How to handle this UML compliant?

Upvotes: 3

Views: 4790

Answers (2)

qwerty_so
qwerty_so

Reputation: 36323

Simply spoken (and to focus on the needed step)

enter image description here

put a boolean condition like above in the Guard. This can be any text. You can write C-style or plain text. I'm not sure about OCL here, but that's for academic purpose anyway (my opinion).

N.B. Your diagram shows Tries = 3 which should be a Guard also (i.e. [Tries = 3]) rather than a Name.

Upvotes: 3

Garth Gilmour
Garth Gilmour

Reputation: 11274

There are a couple of options here:

  1. Your guard condition can combine multiple checks within the '[]' - much like you were doing in the note.
  2. You can have multiple transitions between the same two states, each with its own condition.
  3. You can have states within states. So in your example the three states could be within a superstate of 'Normal Operation' - which you then further define in other documentation or via a note.

All of these are valid UML syntax. But note that just because something is valid doesn't mean it will be supported in your editor. For example it was many years before most of the features of sequence diagrams became available within editors...

Upvotes: 2

Related Questions