UML/SysML: A Boolean "state flag" attribute corresponding to a State can be useful for indicating states in some diagram types (but must be synchronised with Transitions to States carefully).

Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Policy level
Specification keywords
UML keywords
Keywords

Using a Boolean as a "state flag" is quite common in code.

However, if you are just modelling within MagicDraw® UML, the MagicDraw SysML Plugin, Magic Cyber-Systems Engineer® (Cameo Systems Modeler®), or Magic Model Analyst® (Cameo Simulation Toolkit®) this strategy is primarily a communication device. For example, one can use such "state flags" to indicate the state on an InstanceSpecification. However, one has to be very careful that the flag is indeed set correctly on entry to the State in a StateMachine, hence this supporting policy:

In a sense, having both the State in the StateMachine and a flag breaks Single Source of Truth (SSoT) and represents a maintenance burden if you are just using a model within Magic Model Analyst® (Cameo Simulation Toolkit®) . But state information simply can't be shown in all diagram types.

To make it clear that a variable is a state flag you can:

  • Include the word state in the name: isStateExists : Boolean
  • OR Use a custom stereotype keyword: «state» isExists : Boolean

Of course, in general, a State may be associated with more than just one variable.

Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)