Page 87 - Software and Systems Requirements Engineering in Practice
P. 87
58 S o f t w a r e & S y s t e m s R e q u i r e m e n t s E n g i n e e r i n g : I n P r a c t i c e
that cause the change, and one or more actions that take place as the
object transitions from one state to another.
A summary of the different kinds of state tables can be found
in the March 2008 Crosstalk article by Herrmannsdörfer et al.
[Herrmannsdörfer et al. 2008]. As an example, consider the design of
a simple CD player with three buttons (Figure 3.9). The only states
that the player can be in (assuming the power is on) are open, closed
and loaded, closed and empty, and playing (which is only possible if
the player is closed and loaded). There are also well-defined events
that determine what state the player is in, and clear actions to take for
any given event. On an event (in this case pressing a button), one or
more actions are taken, and the player transitions to a different state or
stays in the same state. The particular state table shown is nondeterministic
because if the state is “Open” and the “Open/Close” button is pressed,
there are two possible transitions. If there is a CD in the tray, the player
will transition to state 2 (closed and loaded), whereas if the tray is empty,
the player will transition to state 3 (closed and empty), depending on
whether a CD is detected in the tray. In general, deterministic state
machines, where an event can have only at most one transition from a
given state, are preferred because design and testing is simplified.
However, it is sometimes possible to make a nondeterministic machine
deterministic by adding intermediate states.
Process Modeling Techniques
A variety of process modeling techniques are suitable for the elicitation
of requirements. Just a few of them are listed here, and model-driven
techniques that are suitable for both elicitation and analysis are
described in more detail in Chapter 4.
State
Number State Open/Close Play Stop
1 Open Close Tray No action No action
{if No Disc
Display “No Disc”
go to 3
else Display “Ready”
go to 2}
2 Closed Open Tray Start Playing No action
Loaded {Display “Open”} {Display “Playing”}
Go to 1 Go to 4
3 Closed Open Tray {Display “No Disc”} No action
Empty {Display “Open”} No action
Go to 2
4 Playing Stop Playing {Display “Playing”} Stop Playing
Open Tray No action {Display “Stop”}
{Display “Open”} Go to 2
Go to 1
FIGURE 3.9 Simple CD player