History State

A composite state may contain shallow history and deep history states.

When the control comes to a shallow/deep history state, its action is executed, and the control is immediately passed to the “real” state referred by it.

Transitions may not exit a history state.

To draw a history state
  1. Drag the History State element from the Statechart palette onto the diagram of agent.
  2. In the Properties view, choose whether the history state is deep or shallow.


Name – The name of the history state. The name is used to identify the state within the statechart.

Ignore – If selected, the history state is excluded from the model.

Show name – If selected, the name of the history state is displayed on a presentation diagram.

History type – Defines the type of the history state:
shallow: history state is a reference to the most recently visited state on the same hierarchy level within the composite state.
deep: history state is a reference to the most recently visited simple state within the composite state.

Action – Here you can specify Java statements to be executed when the statechart enters the history state.

The figure above illustrates the difference between shallow and deep history states. Suppose E is the most recently visited simple state inside the composite state A. If the control reaches the deep history state H*, it passes to E, whereas shallow history state H passes the control to C – the most recently visited state on the same hierarchy level. Then the standard procedure of finding the initial state within C is invoked, and the statechart ends up in D.

In case there is no visited state at all within the scope of a history state (no history exists yet), the control goes to the corresponding initial state.


Demo model: Statechart for Product Lifecycle

This demo model contains a statechart describing lifecycle phases of a product. The development process consists of four phases. If the product development is suspended, the statechart control is passed to the Suspended state. When the company decides to resume the product development, the Resume transition is taken. The control is passed to the history state inside the composite NewProductDevelopment state. This history state instantly passes the statechart control to the state that was active when the product development was suspended.

Related topics


Statechart declaration rules

Statechart execution order