Unit 7
Unit 7
Unit 7
7.0 INTRODUCTION
In designing any system or in general life activities, you must have observed that
whenever some actions are triggered, some operation/ something is done. From daily
life, you can see that a ring tone is produced when you press a bell button. This means
some event has taken place as a result of some trigger. The dynamic model covers this
aspect of the systems.
The dynamic model shows the time-dependent behaviour of the system and the
objects in it. Events can be defined as “something that happened at a point of time”.
The logical correctness of events depends on the sequences of interactions or events.
The dynamic model is important for interactive systems
You can understand a system by first looking at its static structure, the structure of its
objects, and their relationships over time. Aspects of a system concerned with time
and changes are represented with the dynamic models. Control describes the
sequences of operations that occur in response to external stimuli, without considering
what operations to do, what they operate on, or how they are implemented.
In this unit, we will discuss the basic concepts of dynamic modeling, covering events
and states. The major dynamic modeling concepts are events, which represent external
stimuli, and states, which represent the values of objects. The state diagram is a
standard computer science concept (a graphical representation of finite state
machines). Emphasis is on using events and states to specify control rather than as
algebraic constructs. We will also cover the state diagram and concept of concurrency.
7.1 OBJECTIVES
After going through this unit, you should be able to:
explain events and transition,
design state diagrams,
explain the elements of the state diagram,
use advanced concepts in dynamic modeling,
explain, concurrency, and
represent the dynamic model of systems.
7.2 EVENTS
1
An event is some action-oriented result, such as mouse click, applying a brake on
a car etc. You might have experienced that the appropriate action takes place
whenever you click on a mouse.
You may observe that an event has no specific time period duration. You can click
on a mouse and keep it pressed as long as you want. So, as far as events are
concerned, nothing is instantaneous. An event is simply an occurrence. An event is
actually a one-way transmission of information from one object to another, but
sometimes it may be an event that occurs on a single object and changes that object's
state.
Two events can take place at the same time or one after the other. Also, any two
events may occur independently of each other or simultaneously. For example, two
trains can depart simultaneously for two different places or depart from the same
place, but one after the other. Any two events can be independent as well as
dependent on each other.
Two events that are unrelated and occur simultaneously are known as concurrent
events. They do not affect each other. In a distributed system, you will notice
concurrent events and activities. You will not find any particular order between the
two events because they can occur in any order.
An object sending an event to another object may expect a reply, but the reply will
be a separate event from the second object. So, you may see conversations between
two objects as a combination of two or more events.
Event Classes: Every event is a unique occurrence; an event class is a name to
indicate common structure and behaviour. Some events are simple signals, but
most event classes have attributes indicating the information they convey. For
example, events like train depart which have the attributes train number, class, city,
etc. Not all the attributes of objects need to contribute to attributes of events.
Here, you must note that the event's time is an implicit attribute of all events.Some
events convey information in the form of data from one object to another. Sometimes,
some classes of events only signal that something has occurred, while other classes of
events convey data values. The data values conveyed by an event are its attributes; it
implies the value of data objects involved in events.
Event class name (attributes)
Sometimes event refers to an event instance or event class. Example of some events:
2
Dynamic Modeling
The state of an object can be decided by the current values associated with the
attributes of that object.
State
A state is a condition during the life of an object, or an interaction during which it
satisfies some condition, performs some action, or waits for some event to occur. An
object remains in a state for a finite (non-instantaneous) time.
Actions are atomic and non-interruptible. A state may correspond to ongoing
activity, such as activity being expressed as a nested state machine. Alternately,
ongoing activity may be represented by a pair of actions, one that starts the activity on
entry to the state and one that terminates the activity on exit from the state. So
you can see that activities are the agents that are responsible for the change in state.
Also, a state has its duration, and most of the time, a state is associated with some
continuous activity.
A state must have initial states and final states. A transition to the enclosing states
represents a transition to the initial state. A transition to a final state represents the
completion of activity in the enclosing region. Completion of activity in all concurrent
regions represents the completion of activity by the enclosing state and triggers a
“completion of activity event” on the enclosing state. Completion of the outermost
state of an object corresponds to its death.
Notation
A state is shown as a rectangle with rounded corners. It may have one or more
compartments. The compartments are all optional. They are as follows:
Name compartment holds the (optional) name of the state as a string. States
without names are “anonymous” and are all distinct. It is undesirable to show
the same-named state twice in the same diagram.
Depart
Bus Stand A
Bus Stand B
At Bus Stand
From Bus Stand B
Statechart Diagrams
3
Objects have behaviours and states. The state of an object depends on its current
activity or condition. A statechart diagram shows the possible states of the object
and the transitions that cause a change in state.
The statechart diagram shown in Figure 7.2 models the login part of an online banking
system. Logging in consists of entering a valid social security number and personal id
number and then submitting the information for validation.
States are rounded rectangles. Transitions are arrows from one state to another. Events
or conditions that trigger transitions are written beside the arrows. Our diagram has
self-transition on Getting PIN.
The initial state (black circle) is a dummy to start the action. Final states are also
dummy states that terminate the action.
The action that occurs as a result of an event or condition is expressed in the form of
action. While in its Validating state, the object does not wait for an outside event to
trigger a transition. Instead, it performs an activity. The result of that activity
determines its subsequent state.
You can observe that a statechart diagram shows the sequences of states that an object
or an interaction goes through during its life in response to received stimuli and its
responses and actions. Or, in other words, you can say that:
“The state machine is a graph of states and transitions that describes the
response of an object of a given class to the receipt of outside stimuli. A state
machine is attached to a class or a method”.
A statechart diagram represents a state machine. State symbols represent the states,
and the transitions are represented by arrows connecting the state symbols. States may
also contain sub diagrams by physical containment and tiling.
4
Dynamic Modeling
3) Draw a state diagram for a mobile phone system.
…………………………………………………………………………………………
………………………………………………………………………………
Now, let us discuss the basics components of a state diagram.
5
Note: Changes in the system that occur, such as a background thread while the main
process is running, are called “substates”. Even though it affects the main state, a
substate is not shown as a part of the main state. Hence, it is depicted as contained
within the main state flow.
6
Dynamic Modeling
2) What are two special events?
…………………………………………………………………………………….……
……………………………………………………………………………..……
………………………………………………………………………………
3) What is a self-transition?
…………………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
……………………………………………………………………………………
………………………………………………………………………………
Now, let us discuss the concept of the concurrent object.
7.6 CONCURRENCY
You are already familiar with the term concurrent lines, which goes without affecting
other operations. Similarly, when objects can change state independently in a system,
they are termed concurrent objects.
In a dynamic model, some systems are described as a set of concurrent objects, each
with its own state and state diagram.
An expansion of a state into concurrent substates is shown by tiling the graphic
region of the state using dashed lines to divide it into subregions. Each subregion is a
concurrent substate. Each subregion may have an optional name and must contain a
nested state diagram with disjoined states.
Composite States
You can say that a state can be decomposed using and-relationships into
concurrent substates or using or-relationships into mutually exclusive disjoint
substates. A given state may only be refined in one of these two ways. Its substates
may be refined in the same way or the other way.
A newly-created object starts in its initial state. The event that creates the object may
be used to trigger a transition from the initial state symbol. An object that transitions
to its outermost final state ceases to exist.
An expansion of a state shows its fine structure. In addition to the (optional) name
and internal transition compartments, the state may have an additional compartment
that contains a region holding a nested diagram. The text compartments may be
shrunk horizontally within the graphic region for convenience and appearance.
Sequential Substates
Dial Number
Partial Dial
Figure 7.4: States Sequence
Entry / start dial Entry / member append (n)
In Figure 7.4, you
tone can
exit/ see
stop that dial a number process state is further divided into its
Dial, Validate
dial tone
sequential substrates such as, when it is entering number state then the state can be
named as “Partial Dial” in which the user is still entering
Digit (n)
the number the action is
“append in digits” then next state will validate the number and so on.
A state diagram for an assembly is a collection of state diagrams, one for each
component. Aggregation means concurrency. Aggregation is the “and-
relationship”, you will see, it is the combined states of all component diagrams. For
example, the state of a Car as an aggregation of components states, the Ignition,
Transmission, Accelerator, and Brake. Each component state also has states. The state
7
of the car includes one substate from each component. Each component undergoes
transitions in parallel with all others.
Semantics
An event is a noteworthy occurrence. For practical purposes in state diagrams, it is
an occurrence that may trigger a state transition. Events may be of several kinds
(not necessarily mutually exclusive): The event occurs whenever the value of the
expression changes from false to true. Note that this is different from a guard
condition: A guard condition is evaluated once whenever its event fires; if it is false,
the transition does not occur, and the event is lost. Guarded transitions for one object
can depend on another object being in a given state.
Mode Button
Display Set Hours
Press
Button/change
Do/Display Current Time Do/Display Hours Hours
Mode Button
In Figure 7.5, you can see that the state diagram of a digital watch is given where the
user wants to set Hours, set Minutes, and then set seconds.
8
Dynamic Modeling
Check Your Progress - 3
1) Give a Concurrent substates diagram for classroom and exam held.
…………………………………………………………………………….……
……………………………………………………………………….……
……………………………………………………………………….
2) Describe the Dynamic Model.
…………………………………………………………………………….……
……………………………………………………………………….
3) Give a sample of a Dynamic Model.
…………………………………………………………………………….……
……………………………………………………………………….……
……………………………………………………………………………
……………………………………………………………………….
4) Show, with an example, that relatively high-level transitions result when outside
events stimulate the system or program.
…………………………………………………………………………….……
……………………………………………………………………….……
……………………………………………………………………….……
……………………………………………………………………….
7.8 SUMMARY
This unit explained dynamic modeling. The dynamic model is the model which
represents the control information: the sequence of events, states and operations that
occur within a system of objects. It has scenarios to occur with meaningful
constraints. This unit explained events and states.An event is triggered by an
instantaneous action. One kind of action is sending an event to another object. An
external event, also known as a system event, is caused by something outside our
system boundary. An internal event is caused by something inside our system
boundary. States may be “nested.” A nested state usually indicates a functional
decomposition within the “super” state. The term macro-state is often used for the
superstate. The macro-state may be composed of multiple micro-states.
The basic notion is that the system is always in one state, and never in more than one
state (at any given level). The system remains in that state until a transition is
triggered by an external event. Transitions take no time to occur. There is no time in
which the system is not in one of the defined states. State diagrams must be created
for state-dependent objects with complex behaviour like Use Cases, Stateful
session, Systems, Windows, Controllers, Transactions, devices, and role mutators.
Actions are associated with transitions and are considered as processes that occur
quickly and are not interrupted.
9
Check Your Progress - 1
1) State diagrams (State Chart Diagram) describe all the possible states that a
particular object can get into and how the object’s state changes as a result of
events that reach the object. It states all possible states and transitions.
2) The UML state diagram is used to represent the states and behaviour of the
system. It shows the events and their impact on the states of the objects in the
system. Also, using a state diagram, one can notice the behaviour of an object in
reaction to an event.
3)
Time out
After 20 Sec
Dial Dight Do/ Play message
Invalid
Do / Play message
Ringing
Talking
Do/ Play ring tone
Incomplete
10
Minor 1 Minor 2
Dynamic Modeling
X
State (Event dependency)
11
7.9 REFERENCES/FURTHER READINGS
12