Page 69 - DCAP308_OBJECT_ORIENTED_ANALYSIS_AND_DESIGN
P. 69
Unit 6: State Modelling
6.1 State Machine Notes
A state machine is a behavior which specifies the sequence of states an object visits during its
lifetime in response to events, together with its responses to those events. Now, we describe the
various concepts related to state machine in the following sub-sections.
6.1.1 Events
An event is the specification of a significant occurrence. For a state machine, an event is the
occurrence of a stimulus that can trigger a state transition. In other words, we can say an event
is something that happens at a point in time. An event does not have duration. An individual
stimulus from one object to another is an event.
Example: Press a button on mouse, airplane departs from an airport are examples of
events.
6.1.2 States
A state is a condition during the life of an object during which it satisfies some condition,
performs some activity, or waits for some external event. A state corresponds to the interval
between two events received by an object and describes the “value” of the object for that time
period. A state is an abstraction of an object’s attribute values and links, where sets of values are
grouped together into a state according to properties that affect the general behavior of the
object. For instance, stack is empty or stack is full are different states of the object stack. As state
corresponds to interval between two events received by an object; therefore, it has duration.
A substate is a state that is nested in another state. A state that has substates is called a composite
state. A state that has no substates is called a simple state. Substates may be nested to any level.
6.1.3 Transition and Conditions
A transition is a relationship between two states indicating that an object in the first state will,
when a specified set of events and conditions are satisfied, perform certain actions and enter the
second state. Transition can be self-transition. It is a transition whose source and target states are
the same. If a transition is to a composite state, the nested state machine must have an initial
state. If a transition is to a substate, the substate is entered after any entry action for the enclosing
composite state is executed followed by any entry action for the substate. If a transition is from
a substate within the composite state, any exit action for the substrate is executed followed by
any exit action for the enclosing composite state. A transition from the composite state may
occur from any of the substates and takes precedence over any of the transitions for the current
substate.
A condition is a Boolean function of object values, such as “the temperature is below freezing.”
A condition is valid over an interval of time.
Example: “The temperature is below freezing from November 15, 1921 until March 3,
1922”.
6.1.4 Action
An action is an executable, atomic (with reference to the state machine) computation. Actions
may include operations, the creation or destruction of other objects, or the sending of signals to
LOVELY PROFESSIONAL UNIVERSITY 63