Announcing Cradle-7.7 - start your free trial here

3SL Reference -Statechart Diagram (SCD)

Statechart Diagram (SCD)

Classes that have a distinct lifecycle, that is, which are believed to exhibit or provide different external behaviour in different circumstances, may be augmented by a Statechart Diagram (SCD). An SCD is a finite-state-machine that describes how the class responds to external stimuli. The stimuli are the receipt of messages by instances of the class, in the form of calls of the class’s operations.

Dynamic behaviour is described in terms of a set of potentially nested states, the transitions between these states, the events (calls of the class’s operations) that trigger these transitions, and actions that are performed, both while transitioning between states, and on entry to, whilst within, and on exit from a state.

Each state has an associated state specification whose name is the same as the state and whose number is the dot-concatenation of the SCD number (the class name) and the state number. The state specification for a state is mandatory, because Cradle stores the set of processing for a state not within the SCD, but within the ACTIVITIES frame in each state’s state specification.

The details of a state are shown as a set of lines of the form: condition/operation in which the conditions entry, exit, and do are, by convention, used to represent processing an entry to a state, processing whilst in a state, and processing on exit from a state.

The SCDs will initially show only terse details for states, but as iterative development progresses, the contents of SCDs and their states will become increasingly detailed.

An SCD has one initial state and one (or possibly more) final states. A transition may be to a superstate, in which case the flow of control begins at the initial state symbol nested within the superstate. A superstate may contain more than one set of nested states and transitions, each set separated from all other sets, and each set having its own initial state and final state(s) symbols. These sets are considered to run concurrently.

A transition from a superstate is considered to come from any or all of the states directly within it.

A superstate may have superstates nested within it, each of which may in turn contain states and transitions, and possibly other superstates. As such, it is possible to create a hierarchy of states within an SCD by nesting states inside superstates, and then nesting superstates inside other superstates.

At each level of state nesting, there may be any number of superstates. For example, an SCD may contain some states and two superstates, each with states nested inside it.

There is consequently the concept of a container symbol and contained symbols, and the concept of a symbol being directly within its container symbol, and possibly being indirectly within other symbols. If a superstate S1 contains a state A and a superstate S2, and superstate S2 contains a state B, then B is directly within S2 and indirectly within S1.

SCDs are not hierarchical. Their connectivity is:

Diagram showing the connectivity of a Statechart Diagram

SCDs are available in models in both the Essential and Implementation Domains.