The sequence diagram belongs to an Object

advertisement
STATECHART DIAGRAMS
Statechart diagram is a graphical representation of a discrete, abrupt behavior of finitestate-transition systems. These diagrams make it possible to trace the behavior of an object
both in a single and in several use cases. They can be used as documentation for direct
generation of code. These diagrams are particularly useful for modeling reactive and real-time
systems.
Basic concepts of the statechart diagrams are: state, transition, initial state and final
state. State is a condition in which an object exists in its life cycle, when it meets a certain
requirement, performs an operation or waits for an event to occur. Transition is a relationship
between two states, indicating that the object being in the first state will perform certain
actions and move to the other state, whenever a specific event occurs and certain conditions
are met. (Fig. 1)
The context of the state and transition concepts is so wide in terms of meaning that it is
necessary to introduce advanced categories of state machine, such as: sections of the graphical
symbol of state, classification of states, orthogonal regions, pseudo-states, types of transitions,
protocol state machine, behavioral state machine and events.
In any state shown graphically the following sections can be defined: name section,
internal operations section, internal transitions section and decomposition section (in case of
complex states). Internal operations section lists the internal operations performed when an
object achieves a certain state. Type of the internal operation is identified by one of the
keywords: entry (an operation automatically performed on the object the moment it achieves
the state, there may be only one within a state), exit (operation performed when an object
leaves the state, there may be only one within a state) or do (operation performed
continuously on the object being in a given state, there can be many such operation within a
state) (Fig. 2). Internal transitions section indicates specific cases of transitions, execution
of which does not lead to a change of state. Internal transitions do not have their own
graphical symbol but are specified in the state area.
The classification of states includes the following three state categories: simple states
(Fig. 1 and 2), composite states and sub-states (Fig. 3 and 4). Simple state is a state that does
not contain any sub-states or orthogonal regions. A composite state is a state which contains
either sub-states or is divided into orthogonal regions. Sub-states can be implicit or explicit.
Hiding sub-states is applied in case of diagrams with complex structure.
Some of the states in composite states are activated concurrently. For showing
concurrency an orthogonal region is used. In this region there are sub-states and transitions
Systems Analysis
Karolina Muszyńska
between them. Transitions can cross composite states boundaries. All orthogonal regions must
be realized in order for the state to be completed (Fig. 4).
Pseudo-state is an abstract category of statechart diagram modeling, which allows for
organizing complex transitions by the use of fork/join nodes, junctions, decision nodes, etc.
We have the following transition types:
-
simple - occurring between the source and target state,
-
return - where the source and target states are the same state,
-
internal – constituting one of the elements of a state,
-
local - indicating transitions between any sub-states of a composite state,
-
external - leaving a composite state and directed to other state or pseudo-state,
-
high level or group - leaving composite states and indicating the necessity of leaving
all sub-states of this composite state before transition,
-
complex – being a chain of transitions which are joined or forked, linked by a junction
or decision node,
-
automatic – without any associated event or condition.
State machines can be divided into: behavioral state machines and protocol state
machines. The former ones present transitions between states of many objects in a wider
context of system, subsystem or use case behavior. The letter ones concentrate on a specific
object and present available and permitted transitions between the states of this object.
Transitions from one state to another are initiated by events, which are stimuli sent by
other objects. There are five types of events:
-
signal – asynchronous stimulus transmitted between two objects (e.g. a signal from a
sensor),
-
call event – calling operations of one object by another object (e.g. login, register),
-
time event – event, which occurs after a certain period of time (e.g. after (3 hrs.)),
-
status change event – event, which occurs at a certain point of time (e.g. when (date =
1 July)
-
deferred event – event, which is not supported within a given state but added to the
deferred events queue (e.g. summary of Receivables /defer)
The statechart diagram creation should follow the following steps:
-
determination of the type of created state machine and identification of objects,
-
identification of possible states of a state machine
-
determination of the hierarchy of states, sub-states and orthogonal regions,
-
linking the states and their sub-states with transitions,
-
application of adequate pseudo-states.
Systems Analysis
Karolina Muszyńska
Fig. 1
Fig. 2
Electronic examination system -
Internal actions of a given state
statechart diagram for Student class object
Edited
Signed in
entry / display form
do / fill in form
do / update progress bar
exit / save data
Accepted
Examined
Evaluated
Fig. 3
Statechart diagram with a sub-state
Received
Submitted
Processed
Approved
Canceled
Realized
Systems Analysis
Karolina Muszyńska
Fig. 4
Statechart diagram with a sub-state and orthogonal region.
Registered
Processed
[everything is ok]
Closed
[deficiencies in documentation]
Suspended
Archived
[dificiencies in documentation]
Assigned
Verified
[everything is ok]
Complemented
Monitored
Systems Analysis
Karolina Muszyńska
Fig. 5
A protocol state machine describing states of an Exam class object.
Start
[previous exam session settled]/ plan exam
Created
/ approve
/ edit
Approved
[number of students > 0]/ begin exam
/ cancel
Activated
[exam time is up]/ terminate exam
Terminated
Canceled
/ cancel
/ calculate result
[revocation time is up]/ delete
Settled
[storage time is up]/ delete
Deleted
Systems Analysis
Karolina Muszyńska
Download