Modeling IT Systems
4.3.3 Statechart Diagram
Figure 4.47 Elements of the statechart diagram
In statechart diagrams, as shown in Figure 4.47, we work with the following elements:
Initial State
The initial state represents the source of all objects:
It is not a normal state, because objects in this state do not yet exist.
State
The state of an object is always determined by its attributes and associations. States in
statechart diagrams represent a
set of those value combinations, in which an object
behaves the same in response to events:
152
Chapter 4
Therefore, not every modification of an attribute leads to a new state.
Transition
A transition represents the change from one state to another:
Internal Transition
An internal transition is a transition from one state to itself. This means that the object
handles the event without changing its state:
The events that initiate the internal transition are listed in the lower part of the state
symbol. For instance, a frequent flyer card object in the state normal remains in the state
normal when the event «
M» add miles occurs.
Mutation Event
A mutation event is the initiator of a transition from one state to another, or for an
internal transition, where the state remains the same:
Action
An action is the activity of an object that is initiated by an event:
An action describes what the object does in response to the event. This description can be
textual or formalized.
153
Modeling IT Systems
Guard Condition
A guard condition is a condition that has to be met in order to enable the transition to
which it belongs:
Guard conditions can be used to document that a certain event, depending on the
condition, can lead to different transitions.
Final State
The final state represents the end of an object's existence:
A final state is not a real state, because objects in this state do not exist anymore.
Reading Statechart Diagrams
Figure 4.48 A Statechart diagram with events
The diagram in Figure 4.48 shows all states that the object plane can be in during the
course of its life. Furthermore, it shows the possible transitions between the states and the
events that initiate these transitions.
Each object of the class plane comes from nowhere (1) (initial state) and disappears
(generally) again, into nothing (10) (final state). This usually holds true for all classes,
meaning in most classes you will find an initial state (1) and a final state (10).
154
Chapter 4
Over the course of its life, an plane (please note: we are here talking about the object
plane and not about a real airplane) can take up three states:
ordered (3), in maintenance
(5), and
ready for use (7)
The event «
M» plane ordered, leads to the occurrence, that from nowhere (1) a new
plane object is created in the IT system (birth). Immediately after it has been created it is
in the state
ordered (3).
If the event «
M» plane delivered (4) occurs, and the plane is the state ordered (3), it
changes to the state
in maintenance (5). If the plane is in any other state than ordered,
nothing happens.
Through the events «
M» plane available (6) and «M»plane not available (8), the plane
changes any number of times between the states
in maintenance (5) and ready
for use (7).
At the end of its life, the airplane object disappears through the event «
M»plane
withdrawn (9) into nothing (10), meaning it will be deleted (death).
Figure 4.49 shows more elements that can occur in statechart diagrams:
Figure 4.49 Statechart diagram with internal transitions and guard conditions.
In addition to the transitions we have already explained, there are also internal transitions.
The event «
M» assign plane (1), which occurs when the plane is assigned to a flight,
initiates no transition to another state. Rather, the plane remains in the state
ready for use
(2). This constitutes an internal transition; the plane object is in the same state
ready for
use (2) before and after the event.
A guard condition allows acceptance or rejection of an event depending on a condition. If
in the state
scheduled for maintenance (3) the event «M» complete flight (4) occurs,
155

Get UML 2.0 in Action A Project-Based Tutorial now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.