State Diagram

From Open Risk Manual

Definition

A State Diagram (also State Machine Diagram) is a behavioral UML diagram that is used to give a description of the behavior of a system. This behavior is represented as a series of events that can occur in one or more possible states. It captures the various possible states of each individual object by modeling the transitions among the various states in a state diagram (or state transition diagram).

Such diagrams show the dynamic behaviour of a class and how an object behaves differently depending on the state that it is in. The representation is as a directed graph in which nodes denote states and connectors denote state transitions. It is well adapted to describe discrete, event-driven behaviors. An event is something that happens that affects the system. There is an initial state and a final state, and the operation generally results in a change of state, with the operations resulting in different states being entered and exited.

The use of state diagrams is typical when objects changes state in a complex way during one or more use cases.


PlantUML Elements

A PlantUML state diagram specifies and shows the following:

  • State



Example

@startuml
skinparam handwritten true

scale 350 width
[*] --> NotShooting

state NotShooting {
  [*] --> Idle
  Idle --> Configuring : EvConfig
  Configuring --> Idle : EvConfig
}

state Configuring {
  [*] --> NewValueSelection
  NewValueSelection --> NewValuePreview : EvNewValue
  NewValuePreview --> NewValueSelection : EvNewValueRejected
  NewValuePreview --> NewValueSelection : EvNewValueSaved

  state NewValuePreview {
     State1 -> State2
  }

}
@enduml

State Diagram

References