A UML state machine diagram shows the behavior of a part of a designed system. How an object responds to an event depends on the state that object is in. A state machine diagram describes the response of an object to outside stimuli. The object can be a computer program, device, or process.
Following are the shapes on the UML State Machine stencil.
Shape |
Description |
---|---|
|
Represents one possible state for the system. |
|
Represents one possible state for the system. After you add it to the diagram, type after each of the "/" characters to specify what actions occur when the system enters the state, while system is in the state, and when the system exists the state. |
|
Represents a state that has sub-states, or nested states. Add other state shapes inside the composite shape. |
|
Represents a composite state whose internal details aren't visible. |
|
Represents the state of an object before any transitions happen. For an object, this could be the state when it's instantiated. |
|
Represents the state of an object in which no transitions lead out of. |
|
Represents a conditional branch in the process flow. It evaluates the guards of the triggers of its outgoing transitions to select only one outgoing transition. |
|
Used as a diagram comment that has no semantic influence on the model elements. |
Following are some shapes on the UML Statechart stencil:
Shape | Description |
---|---|
Transition |
In an statechart diagram, a simple transition is a relationship between two states or action states, or between a state and itself. (A complex transition has multiple source and/or target states.) A simple transition indicates that an object in the first state will enter the second state and perform specified actions. The trigger that makes the transition fire is the occurrence of the event labeling the transition. A transition is shown as a solid arrow from the source state to the target state and is labeled with a transition string. |
Deep History and Shallow History |
Used in a statechart, a history state indicator represents the sub-state last visited. When a transition to the indicator fires, an object resumes the state it last had at the same level as the history indicator. An asterisk ''*'' attached to the ''H'' represents deep history. When a transition to a deep history indicator fires, an object can resume a state at any depth within a complex region. A region may include both a shallow and deep history state indicator. |
Final State |
In a statechart diagram, a final state represents the completion of activity in the enclosing state or action state. A statechart diagram can have one or more final states or, if the system never stops, no final state at all. |
Initial State |
In a statechart diagram, an initial state represents the state of an object before any events included in the diagram have acted on it. A transition from the initial state is usually unlabeled and represents any transition to the enclosing state. The exception is the case of a top level state machine when the transition is labeled with the event that creates the object. There can only be one initial state in a statechart diagram. |
State |
In a statechart or activity diagram, a state is a condition during which an object satisfies a condition, performs an action, or waits for an event. A state is an image of an instant in the life of an object that reflects the values that exist in the object's attributes and the links the object has with other objects. A state has two compartments for optional information. The top compartment contains a name and the bottom compartment contains a list of internal actions or activities performed in response to events. When a state corresponds to ongoing activity, that activity is expressed either as a nested state machine or by a pair of entry and exit actions. For related information, see Work with state shapes in UML statechart diagrams. |
Composite State |
In a statechart diagram, a composite state is a state that has been decomposed into concurrent (representing "and" relationships) or mutually exclusive (representing "or" relationships) substates. For related information, see Work with composite state shapes in UML statechart diagrams. |
Decision |
In an activity diagram or statechart diagram, guard conditions indicate different possible transitions from an action state. If one of these transitions leads to another decision, you can represent that decision with the traditional diamond shape. A decision must have one or more incoming transitions and two or more outgoing transitions, each labeled with a distinct guard condition. |