Using a Boolean as a "state flag" is quite common in code.
However, if you are just modelling within MagicDraw® UML, the MD SysML Plugin, Cameo Systems Modeler®, or 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 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.