In: Computer Science
In what respects does a UML state diagram differ from a state transition diagram?
State Diagram
A state diagram is used to represent the condition of the system or part of the system at finite instances of time. It’s a behavioral diagram and it represents the behavior using finite state transitions. State diagrams are also referred to as State machines and State-chart Diagrams. These terms are often used interchangeably. So simply, a state diagram is used to model the dynamic behavior of a class in response to time and changing external stimuli. We can say that each and every class has a state but we don’t model every class using State diagrams. We prefer to model the states with three or more states.
Uses of statechart diagram –
Basic components of a statechart diagram –
Figure – initial state notation
Figure – transition
Figure – state notation
Figure – a diagram using the fork notation
Figure – a diagram using join notation
Figure – self transition notation
Figure – a state with internal activities
Figure – final state notation
State-Transition Diagrams
State-transition diagrams describe all of the states that an object
can have, the events under which an object changes state
(transitions), the conditions that must be fulfilled before the
transition will occur (guards), and the activities undertaken
during the life of an object (actions). State-transition diagrams
are very useful for describing the behavior of individual objects
over the full set of use cases that affect those objects.
State-transition diagrams are not useful for describing the
collaboration between objects that cause the transitions.
The UML notation for state-transition diagrams is shown below:
Notation
For those not familiar with the notation used for state-transition diagrams, some explanation is in order.
State. A condition during the life of an object in which it satisfies some condition, performs some action, or waits for some event.
Event. An occurrence that may trigger a state transition. Event types include an explicit signal from outside the system, an invocation from inside the system, the passage of a designated period of time, or a designated condition becoming true.
Guard. A boolean expression which, if true, enables an event to cause a transition.
Transition. The change of state within an object.
Action. One or more actions taken by an object in response to a state change.