list of dots

User Manual    [Previous]   [Next]   

History states

The history state of any state is its last-visited substate. This is recorded in order to be able to transition to that substate again when needed.

There are two types of history states: Deep history states and regular history states. Deep history stores the specific substate at the deepest level of nesting, while the regular history stores only the first-level substate.

A transition to a history states is indicated using dot notation, by referring to the state to go back to, followed by a dot and either the symbol H to transition to the regular (first-level) history state, or HStar to transition to deep history. When Umple draws a state machine diagram, the deep history appears as H*.

Transitions to history are most commonly used when the system has had to leave normal operation temporarily and needs to later return to exactly what it was doing. Deep history is often appropriate when returning to normal operation, but sometimes regular history is needed in order to allow some form of reinitialization of a substate. When transitioning to history, if there is more than one level of nesting (i.e. the history state has substates), the state machine will enter the start substate of the history state.


//The class Machine uses both deep history 
//and regular history states.

//When the event emergency occurs, the 
//state of normalOperation is stored. 
//When the issue is resolved, depending
//on the intended behaviour, the state
//machine goes back to the specific 
//substate it was previously in (HStar)
//or it restarts the phase it was in (H)

class Machine {
  sm {
    initializing {readyForOperation -> normalOperation;}
    normalOperation {
      phase1 { completePhase1 -> phase2;}
      phase2 {
        subphase2a { complete2a -> subphase2b;}
        subphase2b {}
        completePhase2 -> phase3;
      phase3 {}
      emergency -> handleEmergency;
    handleEmergency {
      resolveEmergency -> normalOperation.HStar;
      resolveButCleanup2a -> normalOperation.H;
// @@@skipphpcompile Php does not generate proper
// history state code (see issue 1338)

Load the above code into UmpleOnline


Another Example

//The class DrawingTool uses a history
//state to get back to the state it was
//previously in after a selection

class DrawingTool {
  sm {
    drawing {
      idle {
        penPress -> drawingStroke;
        colorChange -> changingColor;
      drawingStroke {
        entry / {
          /*deal with the stroke*/
        endStroke -> idle;
      changingColor {
        colorSelected -> idle;
      changeMode -> selecting;
    selecting {
      selectionCompleted -> drawing.H;

Load the above code into UmpleOnline