KEMBAR78
Chapter Four - Ooad Dynamic Modelling | PDF | System | Concurrency (Computer Science)
0% found this document useful (0 votes)
15 views8 pages

Chapter Four - Ooad Dynamic Modelling

Chapter Four discusses dynamic modeling in object-oriented analysis and design (OOAD), focusing on how objects respond to events over time. It outlines the steps for creating dynamic models, including identifying states and events, constructing state transition diagrams, and validating them. Key concepts include states, transitions, events, and actions, with examples illustrating the behavior of objects in various scenarios.

Uploaded by

kiddosatoru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views8 pages

Chapter Four - Ooad Dynamic Modelling

Chapter Four discusses dynamic modeling in object-oriented analysis and design (OOAD), focusing on how objects respond to events over time. It outlines the steps for creating dynamic models, including identifying states and events, constructing state transition diagrams, and validating them. Key concepts include states, transitions, events, and actions, with examples illustrating the behavior of objects in various scenarios.

Uploaded by

kiddosatoru
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

CHAPTER FOUR - OOAD DYNAMIC MODELLING

Dynamic Modelling

After the static behavior of the system is analyzed, its behavior with respect to time and external
changes needs to be examined. This is the purpose of dynamic modelling.

Dynamic Modelling can be defined as “a way of describing how an individual object responds to
events, either internal events triggered by other objects, or external events triggered by the
outside world”.

The process of dynamic modelling can be visualized in the following steps

 Identify states of each object

 Identify events and analyze the applicability of actions

 Construct dynamic model diagram, comprising of state transition diagrams

 Express each state in terms of object attributes

 Validate the state–transition diagrams drawn

The dynamic model represents the time–dependent aspects of a system.

It is concerned with the temporal changes in the states of the objects in a system. The main
concepts are −

 State, which is the situation at a particular condition during the lifetime of an object.

 Transition, a change in the state

 Event, an occurrence that triggers transitions

 Action, an uninterrupted and atomic computation that occurs due to some

event, and

 Concurrency of transitions

1
A state machine models the behavior of an object as it passes through a number of states in its
lifetime due to some events as well as the actions occurring due to the events. A state machine is
graphically represented through a state transition diagram.

States and State Transitions

State

The state is an abstraction given by the values of the attributes that the object has at a particular
time period. It is a situation occurring for a finite time period in the lifetime of an object, in
which it fulfils certain conditions, performs certain activities, or waits for certain events to occur.
In state

transition diagrams, a state is represented by rounded rectangles.

Parts of a state

i. Name − A string differentiates one state from another. A state may not have any name.
ii. Entry/Exit Actions − It denotes the activities performed on entering and on exiting the
state.
iii. Internal Transitions − The changes within a state that do not cause a change in the state.
iv. Sub–states − States within states.

Initial and Final States

The default starting state of an object is called its initial state. The final state indicates the
completion of execution of the state machine. The initial and the final states are pseudo-states,
and may not have the parts of a regular state except name. In state transition diagrams, the initial
state is represented by a filled black circle. The final state is represented by a filled black circle
encircled within another unfilled black circle.

Transition

A transition denotes a change in the state of an object. If an object is in a certain state when an
event occurs, the object may perform certain activities subject to specified conditions and change
the state. In this case, a state−transition is said to have occurred. The transition gives the

2
relationship between the first state and the new state. A transition is graphically represented by a
solid directed arc from the source state to the destination state.

The five parts of a transition are −


i. Source State − The state affected by the transition.
ii. Event Trigger − The occurrence due to which an object in the source state undergoes a
transition if the guard condition is satisfied.
iii. Guard Condition − A Boolean expression which if True, causes a transition on receiving
the event trigger.
iv. Action − An un-interruptible and atomic computation that occurs on the source object
due to some event.
v. Target State − The destination state after completion of transition.

Example

Suppose a person is taking a taxi from place X to place Y. The states of the person may be:
Waiting (waiting for taxi), Riding (he has got a taxi and is travelling in it), and Reached (he has
reached the destination). The following figure depicts the state transition.

Events

Events are some occurrences that can trigger state transition of an object or a group of objects.
Events have a location in time and space but do not have a time period associated with it. Events
are generally associated with some actions.

Examples of events are mouse click, key press, an interrupt, stack overflow, etc.

3
Events that trigger transitions are written alongside the arc of transition in state diagrams.

Example

Considering the example shown in the above figure, the transition from Waiting state to Riding
state takes place when the person gets a taxi.

Likewise, the final state is reached, when he reaches the destination. These two occurrences can
be termed as events Get Taxi and Reach Destination. The following figure shows the events in a
state machine.

External and Internal Events

External events are those events that pass from a user of the system to the objects within the
system. For example, mouse click or key−press by the user are external events.

Internal events are those that pass from one object to another object within a system. For
example, stack overflow, a divide error, etc.

Deferred Events

Deferred events are those which are not immediately handled by the object in the current state
but are lined up in a queue so that they can be handled by the object in some other state at a later
time.

Event Classes

4
Event class indicates a group of events with common structure and behavior. As with classes of
objects, event classes may also be organized in a hierarchical structure. Event classes may have
attributes associated with them, time being an implicit attribute. For example, we can consider

the events of departure of a flight of an airline, which we can group into the following class −

Flight Departs (Flight No, From City, To City, Route)

Actions

Activity

Activity is an operation upon the states of an object that requires some time period. They are the
ongoing executions within a system that can be interrupted. Activities are shown in activity
diagrams that portray the flow from one activity to another.

Action

An action is an atomic operation that executes as a result of certain events.

By atomic, it is meant that actions are un-interruptible, i.e., if an action starts executing, it runs
into completion without being interrupted by any event. An action may operate upon an object
on which an event has been triggered or on other objects that are visible to this object. A set of
actions comprise an activity.

Entry and Exit Actions

Entry action is the action that is executed on entering a state, irrespective of the transition that led
into it.

Likewise, the action that is executed while leaving a state, irrespective of the transition that led
out of it, is called an exit action.

Scenario

Scenario is a description of a specified sequence of actions. It depicts the behavior of objects


undergoing a specific action series. The primary scenarios depict the essential sequences and the
secondary scenarios depict the alternative sequences.

Diagrams for Dynamic Modelling

5
There are two primary diagrams that are used for dynamic modelling −

i. Interaction Diagrams

Interaction diagrams describe the dynamic behavior among different objects. It comprises of a
set of objects, their relationships, and the message that the objects send and receive. Thus, an
interaction models the behavior of a group of interrelated objects.

The two types of interaction diagrams are −

 Sequence Diagram − It represents the temporal ordering of messages in a tabular manner.

 Collaboration Diagram − It represents the structural organization of objects that send and
receive messages through vertices and arcs.

ii. State Transition Diagram

State transition diagrams or state machines describe the dynamic behavior of a single object. It
illustrates the sequences of states that an object goes through in its lifetime, the transitions of the
states, the events and conditions causing the transition and the responses due to the events.

Concurrency of Events
In a system, two types of concurrency may exist. They are –

i. System Concurrency

Here, concurrency is modelled in the system level. The overall system is modelled as the
aggregation of state machines, where each state machine executes concurrently with others.

ii. Concurrency within an Object

Here, an object can issue concurrent events. An object may have states that are composed of sub-
states, and concurrent events may occur in each of the sub-states.

Concepts related to concurrency within an object are as follows –

i. Simple and Composite States

6
A simple state has no sub-structure. A state that has simpler states nested inside it is called a
composite state. A sub-state is a state that is nested inside another state. It is generally used to
reduce the complexity of a state machine. Sub-states can be nested to any number of levels.

Composite states may have either sequential sub-states or concurrent sub-states.

ii. Sequential Sub-states

In sequential sub-states, the control of execution passes from one sub-state to another sub-state
one after another in a sequential manner. There is at most one initial state and one final state in
these state machines.

The following figure illustrates the concept of sequential sub-states

Concurrent Sub-states

In concurrent sub-states, the sub-states execute in parallel, or in other words, each state has
concurrently executing state machines within it.

Each of the state machines has its own initial and final states. If one concurrent sub-state reaches
its final state before the other, control waits at its final state. When all the nested state machines
reach their final states, the sub-states join back to a single flow.

The following figure shows the concept of concurrent sub-states.

7
State Transition diagram for ATM system.

You might also like