State machines

In UML modeling, a state machine is a specification of the dynamic behavior of individual class objects, use cases, and entire systems. With the exception of operations, when you create a state machine, the object that you attach the state machine to becomes the owner of the state machine. When you create a state machine for an operation, the operation becomes the owner of the state machine. A blank state machine diagram opens when you create a state machine. A state machine diagram is a graphical representation of the sequence of states of an object, the events that cause a transition from one state to another, and the actions that result from a change in state. You can add diagrams to a state machine to describe different behavioral aspects of an object.

You can create state machines to describe classes and systems that have significant behavior. Not all objects require state machines. If an object's behavior is basic, if it simply stores or retrieves data, the behavior of the object might not be important to you and its state machine might be of little interest. State machines can also contain nested states that represent different hierarchical state levels. You can use nested states to examine complex state changes in objects.

You can add diagrams to a state machine to describe different perspectives of the behavior of an object. Each diagram opens as a separate window but the same model elements are displayed in all diagrams. The diagrams within a state machine are synchronized by default. Changes made to a region in the Model Explorer view are reflected in the other diagrams of the same state machine and changes made to a region in a diagram are reflected in the Model Explorer view. You can change the edit settings of a region so that changes made to a region in the Model Explorer view are not reflected in the corresponding state machine diagrams and so that a region can be edited independently of other diagrams in the same state machine by changing the canonical properties value of a region to false.

State machines are useful modeling aids for developing real-time or event-driven systems because they show dynamic behavior. You can develop state machines during all phases of a software project and for business modeling. You can use state machines in the following situations:

You can create a state machine for the following objects:

Event-driven behavior

You can use state machines to model event-driven behavior. Events such as time, signals, or operations can cause the state of an object to change. An event has no duration and can precede or follow another event. States that model event-driven behavior continue in the same state until the arrival of an event. After the state responds to an event, the process reverts to a stable state that is ready to receive the next event.

Related tasks
Modeling object behavior by using state machine diagrams
Creating state machines
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.