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:
SCDs are available in models in both the Essential and Implementation Domains.
Each class may have zero or one SCD, which will be numbered and named to match the class. A class’s optional SCD therefore augments the description of the class shown in the CD(s) and described in the class’s specification.
An example SCD is:
The symbols available in SCDs are:
Symbol | Name | Description | Definition | Expansion |
---|---|---|---|---|
Comment | Makes a note anywhere in the diagram. Are always surrounded by * characters. Note: If you do not want Cradle to automatically add an * go to the Graphics Settings section of Project Setup and turn off the Automatically add asterisks to diagram's comment symbols option. | None | None | |
Initial State | A condition at the beginning of the life of an object or an interaction during which it satisfies some condition, performs some action, or waits for some event. | None | None | |
Final State | A condition at the end of the life of an object or an interaction during which it satisfies some condition, performs some action, or waits for some event. | None | None | |
State | A condition during the life of an object or an interaction during which it satisfies some condition, performs some action, or waits for some event. | State specification | None | |
Super-State | A state that contains other states. | None | None | |
History Indicator | When a transition to a superstate occurs, a History Indicator shows control resumes at the state within the superstate that was current when the superstate was interrupted. | None | None | |
Picture | Allows you to choose the location of a GIF or JPEG image to be displayed as a diagram symbol or to be embedded in an existing diagram symbol. | None | None | |
Transition | A relationship between two states, indicating that an object in the first state will enter the second state and perform certain specified actions when a specified event occurs, if specified conditions are satisfied. | None | None | |
Item | Represents a requirement or system note in the diagram. | None | None | |
Context Item | Represents a requirement or system note in a diagram and is a container within which other object symbols can be drawn or attached. | None | None | |
Cross Reference Link | Represents a cross reference that exists between a pair of system notes/requirements. It can also represent a cross reference between a system note/requirement and a specification or data definition or system that describes the objects symbols that it connects. | None | None |