0% found this document useful (0 votes)
120 views

OOMD Module2 Dynamic Modelling

This document provides an overview of dynamic modeling concepts including events, states, state diagrams, and operations. Events represent external stimuli to a system and can pass information between objects. States represent the values of an object at a given time. A state diagram shows the transitions between states in response to events with or without conditions. Operations like activities and actions can be associated with states and events.

Uploaded by

vidhya_bineesh
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

OOMD Module2 Dynamic Modelling

This document provides an overview of dynamic modeling concepts including events, states, state diagrams, and operations. Events represent external stimuli to a system and can pass information between objects. States represent the values of an object at a given time. A state diagram shows the transitions between states in response to events with or without conditions. Operations like activities and actions can be associated with states and events.

Uploaded by

vidhya_bineesh
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 58

Module 2: Dynamic modeling

Vidhya P.M

Dynamic Modeling

First examine the system at a single moment of time.


Then examine changes to objects and their
relationships over time.
Those aspects of a system that are concerned with
time and changes are dynamic model, in contrast with
static or object model.
Control is the aspect of a system that describes the
sequences of operations that occur in response to
external stimuli without considering what the operation
do, what they operate on, and how they are
implemented.

Vidhya P.M

concepts
Events represent external stimuli
States values of objects
State diagram

Vidhya P.M

Events

It is something that happens at a point in time,


with no duration

An individual stimulus from one object to another


is an event.

One event may logically precede or follow


another or the two events may be unrelated.

The two events are casually related.

The two events are casually unrelated are said


to be concurrent i.e. they have no effect on each
other.
Vidhya P.M

An event is a one-way transmission of


information from one object to another.

In real world,
concurrently.

An object sending an event to another


object may expect a reply but the reply is
a separate event under the control of the
second object which may or may not
choose to send it.

all

Vidhya P.M

objects

exist

Every event is a unique occurrence, but we group


them into event classes and give each event class a
name to indicate common structure and behavior.

E.g. flight 123 departs from Delhi and flight 321


departs from Rome are instances of event class
airplane flight departs having attributes airline flight no,
city.

The time at which an event occurs is an implicit


attribute of all events.

Vidhya P.M

An event conveys information from one


object to another.
Some classes of events may be simply
signals that something has occurred
while other convey data values i.e.
attributes.
Showing attributes is optional.

Vidhya P.M

Airplane flight departs (airline, flight#, city)


Mouse button pushed (button, location)
Input string entered (text)
Phone receiver lifted
Digit dialed (digit)

Event classes and attributes

Vidhya P.M

Scenarios and event traces

A scenario is a sequence of events that occurs


during one particular execution of a system.

The scope of a scenario can vary; it may


include all events in the system or it may
include only those events generated by certain
objects in the system.

Vidhya P.M

Caller lifts receiver


Dial tone begins
Caller dials digit (5)
Dial tone ends
Caller dials digit (5)
Caller dials digit (4)
Caller dials digit (3)
Caller dials digit (2)
Caller dials digit (1)
Called phone begins ringing
Ringing tone appears in calling phone
Called party answers
Called phone stops ringing
Ringing tone disappears in calling phone
Phones are connected
Called party hangs up
Phones are disconnected
Caller hangs up
Scenario for phone call
Vidhya P.M

10

The next step after writing scenario is to identify the


sender and receiver objects of each event.

The sequence of events and the objects exchanging


events are shown in event trace diagram.

This diagram shows each object as a vertical line and


each event as a horizontal arrow from the sender to
receiver objects.

Time increases from top to bottom.

Sequences of events are shown not their exact timing.


Vidhya P.M

11

Event trace for phone call


Caller
phone line
Caller lifts receiver
Dial tone begins
Caller dials digit (5)
Dial tone ends
Caller dials digit (5)
Caller dials digit (4)
Caller dials digit (3)
Caller dials digit (2)
Caller dials digit (1)
Called phone begins ringing

callee

two
concurrent
events

ringing stops
phones are connected
disconnected
Caller hangs up

Vidhya P.M

phone rings
answer phone
ringing stops
phones connected
Callee hangs up
disconnected

12

States

It is an abstraction of the attribute values and links of


an object.
Set of values are grouped together into a state
according to properties that affect the gross behavior
of the object.
A state specifies the response of the object to input
events.
Response is same for all values within the same state
and may be different for values in different states.
Response of an object to an event may include an
action or change of states by the object.

Vidhya P.M

13

A state has duration


An event separates two states and a
state separates two events.
In defining states we ignore those
attributes that do not affect the behavior
of the objects.

Vidhya P.M

14

State diagram
It relates events and states.
When an event is received, the next
state depends on the current state as
well as the event; a change of state
caused by an event is called a transition.
State diagram is a graph whose nodes
are states and whose directed arcs are
transitions labeled by event names.

Vidhya P.M

15

State diagram for phone line


On-hook

On-hook

idle
Off-hook
Dial tone

Timed- out

Digit(n)
dialing
Busy tone
Fast busy tone

Num busy

Trunk busy

valid

Recorded message
Invalid no

connecting
routed
ringing
Called phone answers
connected
Called phone hangs up
disconnected

A state diagram describes the behavior of a


single class.
Since all instances of a class have same
behavior they all share the same state
diagram as they all share the same class
features.
But as each object has its own attribute values
so each object has its own state.
Each object is independent of the other
objects and proceeds as its own pace.
Vidhya P.M

17

State diagrams can represent one-shot life cycles or continuous loops.


One-shot diagrams represent objects with nite lives. A one-shot diagram has
initial and nal states.
The initial state is entered on creation of an object
Entering the nal state implies destruction of the object.

Vidhya P.M

18

nal state
(bull's eye)

initial state
(solid circle)
Start

White's
turn

black
moves
Black's
turn

checkmate

Black wins

stale
mate
white
moves
mate
stale

Draw

White wins

checkmate

One-shot
state diagram
One shot

The dynamic model is a collection of state diagrams that interact with each other
via shared events. An object model represents the static structure of a system, while
dynamic model represents the control structure of a system.
A scenario is to a dynamic model as an instance diagram is to an object model.

Conditions
A condition is a Boolean function of
object values.
When Ram goes out in morning( event),
if the temperature is below freezing(
condition), then he puts on his gloves
(next state).
Notation is [condition]

Vidhya P.M

20

Example

[number.isValid()]
Starting
entry / start dial tone
exit / end dial tone

dialed (n)

Dialing
entry / number.append(n)

dialed (n)

21

Operations

An activity is an operation that takes time to complete.


An activity is associated with a state.
Notation do:A within a state box indicates that activity A starts
on entry to the state and stops on exit.
An action is an instantaneous operation.
An operation is associated with an event.
An action represents an operation whose duration is insignificant
compared to the state diagram e.g. disconnect phone line might
be an action in response to an on_hook event for phone line.
Actions can also represent internal control operations such as
setting attributes or generating other events.
The notation for an action is (/) and the name of action, following
the name of the event that causes it.

Vidhya P.M

22

Action for pop-up menu

Right button down/display menu


idle

Menu visible

Right button up/erase menu

Cursor moved/highlight menu item

Vidhya P.M

23

Summary of Notation for State Diagrams with


Operations

State1
do:activity1

Event1 (attributes)[condition1]/action1

Vidhya P.M

State2
do:activity1

24

State Chart Diagram vs Sequence Diagram

State chart diagrams help to identify:

Changes to an individual object over time

Sequence diagrams help to identify

The temporal relationship of between objects over


time
Sequence of operations as a response to one or
more events

Example of Concurrency within an Object


Splitting control

Synchronization

Emitting

Do: Dispense
Cash

Setting
Up

Cash taken

Ready
to r eset

Ready
Do: Eject
Card
Card taken

Modeling Concurrency
Two types of concurrency
1. System concurrency
State of overall system as the aggregation of state diagrams,
one for each object. Each state diagram is executing
concurrently with the others.

2. Object concurrency

An object can be partitioned into subsets of states (attributes


and links) such that each of them has its own subdiagram.
The state of the object consists of a set of states: one state
from each subdiagram.
State diagrams are divided into subdiagrams by dotted lines.

Sate generalization
A nested state diagram is a form of
generalization on states.
Generalization is or-relation.
States may have sub states that inherit
the transitions of their super states just
as classes have subclasses that inherit
the attributes and operations of their
super classes.

Vidhya P.M

28

Sate of car transmission with


generalization
Transmission

Push R
Neutral

Reverse
Push N

Push N

Push F

Forward
Stop

upshift
First

upshift
Second

downshift

Third
downshift

Vidhya P.M

29

State Generalization
Generalization is the or-relationship. The states in the nested diagram are all

renements of the state in the high-level diagram.


States may have substates that inherit the transitions of their superstates. Any
transition or action that applies to a state applies to all its substates, unless overridden
by an equivalent transition on the substate.
A superstate is drawn as a large rounded box enclosing all of
its substates. Substates in turn can enclose further substates.
State diagram of
Within state Forward, substate First is the default initial
car transmission
state. Forward is just an abstract class state; control must
with
be in a real state, such as First.
generalization
push R
push N

Transmission
Neutral

inherited
by each
gear

push F

push N
default
substate

Forward

superstate
abstract state

upshift

stop
First

upshift
Second

downshift

Reverse

Third

downshift

substate

An aggregation
and its
concurrent state
diagrams
Car

Ignition

Transmission

Brake

Accelerator

Ignition
Off

turn key to start


[Transmission in Neutral]

turn key off

Starting

release key

On

push R
push N

Transmission
Neutral

Reverse

push F

push N
Forward

stop

upshift
First

upshift
Second

downshift

Third

downshift

Accelerator

Brake

depress accelerator
Off

depress brake
On

release accelerator

Off

On

release brake

Accelerator

Brake
press

press
Off

Release

On

Off

Vidhya P.M

Release

On

33

Functional Modeling

Vidhya P.M

34

It specifies the results of a computation


without specifying how or when they are
computed.
It specifies the meaning of operations in
object model and actions in dynamic
model as well as constraints in object
model.

Vidhya P.M

35

DFD

It shows the functional relationships of the


values computed by a system, including input
values, output values and internal data stores.
A DFD is a graph showing the flow of data
values from their sources in objects through
processes that transform them to their
destinations in other objects.

Vidhya P.M

36

Elements of DFD
Processes -> Transform data
ProcessName
Data flow -> move data
Actor ->objects that produce and consume
data. actorName
Data store -> objects that store data
passively.

Information/operation
that modify stored data

Data_storeName

Information received from


stored data
Vidhya P.M

37

Data Stores

It is a passive object within the graph that


stores data.
It does not generate any operation but merely
responds to requests to store and access
data.
It is drawn as a pair of parallel lines containing
the name of the store.
Input arrows indicate information or operations
that modify the stored data.
Output arrows indicate information retrieved
from data store.
In general data store is implemented as a file.
Vidhya P.M

38

Data store for temprature readings..

Max temp
Readings
Min temp

Vidhya P.M

39

Data store for bank account


Account
balance
Customer

withdraw

Double headed arrow indicates that balance is both an i/p and o/p of
Subtract operation.

Vidhya P.M

40

Data store for price list for items


Item_name
Price list
cost

Item name Find cost cost

Vidhya P.M

41

A data flow that generates an object


used as the target of another operation is
indicated by a hollow triangle at the end
of data flow.

Bank

accounts

Account

select

balance

name

request
Customer

update ( i/p and o/p)

Selection with an object as result


Vidhya P.M

42

Creation of new object

Create account

account

Bank

Name, deposit
Customer

account

Account

Vidhya P.M

43

Nested DFD
The nesting of a diagram is also called
leveling.
A process can be expanded into another
DFD.

Vidhya P.M

44

Control Flows

A data flow diagram shows all possible


computation paths for values.

Decisions and sequencing are control


issues that are part of dynamic model.

Vidhya P.M

45

A control flow is a Boolean value that


affects whether a process is evaluated or
not.
It is shown by a dotted line from a
process producing a Boolean value to
the process being controlled.

Vidhya P.M

46

Coded password

Account

verify
password

customer

Password
OK
amount

balance

update
cash

Vidhya P.M

47

Specifying Operations

Each operation may be specified asMathematical functions


Table of input and output values.
Equations
Pre and post conditions
Decisions tables
Pseudo code, etc

Vidhya P.M

48

Specification of an operation includes a


signature and a transformation.
Signature defines the interface to the
operation i.e. arguments, value returns.
The transformation defines the effect of
an operation i.e. the output values and
the side effects of the operation on its
operand objects.

Vidhya P.M

49

Operations can be divided into three


partsQueries
Actions
Activities

Vidhya P.M

50

Query

A query is an operation that has no side


effects on externally visible state of any object.
An action is a transformation that has side
effects on the target object or other objects in
the system reachable from the target object.
Actions can be defined by mathematical
equations, decision trees, decision tables, etc.

Vidhya P.M

51

Activity
It is an operation to or by an object that
has duration in time.
It has inherently side effects because of
its extension in time.
Activity only make sense for actors.

Vidhya P.M

52

constraints

It shows the relationship between two objects at the


same time (frequency and wavelength )Or between
different values of the same object at different times
(no of outstanding shares of mutual fund).
It can appear in each model.
Object constraints specify that some objects depend
entirely or partially on other objects.
Dynamic constraints specify relationships among the
states or events of different objects.
Functional constraints specify restrictions on
operations.
A constraint between values of an object over time is
called as invariant i.e. it specifies that some functions
of values remain constant over time.
Vidhya P.M

53

FM Vs OM & DM
FM shows what has to be done by a
system.
The object model shows the doers- the
object.
DM shows the sequences in which the
operations are performed.
The three models come together in the
implementation of methods.
FM is a guide to the methods.

Vidhya P.M

54

A process is usually implemented as a


method.
Actors and data stores are objects in the
object model.
Data flows are values in object model.

Vidhya P.M

55

Relative to functional model the object


model shows the structure of the actors,
data store and flows.
Relative to functional model the dynamic
model shows the sequence in which
processes are performed.

Vidhya P.M

56

Relative to object model the functional


model shows the operations on classes
and the arguments of each operations.
Relative to object model the dynamic
model shows the states of each object
and the operations that are performed as
it receives events and changes state.

Vidhya P.M

57

Relative to dynamic model the functional


model shows the definition of actions
and activities that are undefined with
dynamic model.
Relative to dynamic model the object
model shows what changes state and
undergoes operations.

Vidhya P.M

58

You might also like