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

lect 11

The document outlines exercises related to Data Flow Diagrams (DFD) for a Video Rental Store Software and a Personal Library System, detailing membership processes, item loans, and returns. It also discusses state chart diagrams, highlighting the advantages of hierarchical state machines over finite state machines, including features like nested and concurrent states. Additionally, it covers the syntax and semantics of UML state machines, emphasizing the importance of managing complexity in system design.

Uploaded by

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

lect 11

The document outlines exercises related to Data Flow Diagrams (DFD) for a Video Rental Store Software and a Personal Library System, detailing membership processes, item loans, and returns. It also discusses state chart diagrams, highlighting the advantages of hierarchical state machines over finite state machines, including features like nested and concurrent states. Additionally, it covers the syntax and semantics of UML state machines, emphasizing the importance of managing complexity in system design.

Uploaded by

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

DFD Exercises

1
1. Video Rental Store Software

A video rental store has a large collection of video CDs and
music CDs as loanable items.

A person can become member a member by depositing Rs.
1000 and filling up details such as name, address, and
telephone number. A member id is displayed on successful
membership.

Whenever the store purchases a new item, details such as
price and date of procurement are entered.

A member can, at a time, take on loan at most three
loanable items. The details are entered by a store clerk
and a receipt indicating the daily rental charge should be
printed by the software.

Whenever a member returns his loaned item(s), the clerk
enters the details and the due amount to be paid is
displayed. 2
Manager Loan Details+
Return Details Clerk

Item
Details
Video Due Amount
Store
Member Automation
Id Software

Customer Membership
Details

Context Diagram
3
t e m s
I a il
t
Create Record De
Member
Id Member Item

Item Data
Personal
Return
Details Member Data
Details

Loan Return
Item Item Due Amoun

ils
a
et
D
an 4

L o
2. Personal Library System

A person can have a few hundreds of books. The details of all the books such as
name of the book, year of publication, date of purchase, price, and publisher must
be entered. A book is to be given a unique serial number by the computer which
would be written by the owner using a pen on the book. Before a friend can be
lent a book, he must be registered. The registration data would include name of
the friend, address, land line number, and mobile number. Before a friend is
issued a book, the various books outstanding against him also with the date
borrowed are displayed. The date of issue and the title of the book are stored.
When a friend returns a book, the date of return is stored and the book is
removed from his borrowing list. Up on query, the software should display the
name, address, and telephone numbers of each friend against whom books are
outstanding along with the titles of the outstanding books and the date on which
those were issued. . The owner should be able to query about the availability of a
particular book, the total number of books in the personal library,

The owner of the library software, when he borrows books from his friends, would
enter the details regarding the title of books borrowed, and the date borrowed.
Similarly, the return details of books would be entered. The software should be
able display all the books borrowed from various friends. The owner should be
able to query about the availability of a particular book, the total number of books
in the personal library,

5
UML State Machine
Model

6
State Chart Diagram

FSMs suffer from a few severe shortcomings:

What are the shortcomings of FSM?


State chart is based on the work of David
Harel [1990]:
 Overcomes important shortcomings of FSM
¯
Extends FSM in 2 major ways: Concurrent
states and hierarchy.

7
Robot: State Variables

Power: On, OFF

Movement: Walk, Run

Direction: Forward, Backward,
left, Right

Left hand: Raised, Down How many
states in the

Right hand: Raised, down state machine
model?

Head: Straight, turned left, turned right

Headlight: On, Off
FSM: exponential

Turn: Left, Right, Straight rise in number of
states with state
variables 8
Event State
turnOn Activated
turnOff Deactivated (Idle)
stop Stopped
walk Walking
run Running
raiseLeftArm LeftArmRaised
lowerLeftArm LeftArmLowered
lowerLeftArm LeftArmLowered
raiseRightArm RightArmRaised
lowerRightArm RightArmLowered
turnHead HeadTurned(direction)
9
speak Talking(text)
State Chart Diagram Cont…


State chart avoids two problems of FSM:
 State explosion
 Lack of support for representing
concurrent states


A hierarchical state model:
 Makes use of composite states --- OR
and AND states.

10
Features of State Charts

Two major features introduced :
 Nested states S1
S2
 Concurrent states
Nested State

Several other features
have also been added:
 History state s11 s21

 Broadcast messages
 Actions on state entry and exit s12 s22

 … Concurrent State

11
Nested State Diagrams

Hierarchical organization
is a classic way to control
complexity:
 of programs superstate

 of documentation
 of objects
 …

Why not state diagrams?
 superstates
substates
 substates 12
State Chart Diagram
Cont…


Basic elements of state chart diagram:
 Initial State: A filled circle
 Final State: A filled circle inside
Off Alarm
a larger circle
 State: Rectangle with rounded corners
 Transitions: Arrow between states, also
boolean logic condition (guard)


State chart in UML is called state
machine:
 As it not only models state behavior but 13
14
State Machine Diagram


State machine is the code that
implements a model and runs on a
computer.

In contrast, a state chart is a
description of a state machine.

15
UML State Machine Diagram: Syntax

A state is drawn with a
round box, with three
compartments for: Name sometimes
 name state variables
left out when
empty
 state variables actions
 actions performed

A transition is drawn
with a labeled arrow,
 event causing the
transaction
AnEvent [guard] / SomeAction
 guard condition
 Action to perform 16
Syntax of UML State machine

• State: Rectangle with rounded corners


• Name tab
• Action label:
 Entry Typing
password
 Exit Entry/ set echo invisible
Exit / set echo normal
 Do
Do / read character

17
Predefined Action Labels

“entry/”
 Identifies an action to be
performed upon entry to the state

“exit/”
 Identifies an action to be performed upon exit from the
state (exit action)

“do/”
 Identifies an ongoing activity (“do activity”) that is
performed as long as the modeled element is in the
state or until the computation specified by the action
expression is completed
18
“Do” Activities

The thread executes until:
 The action completes or
 The state is exited through an outgoing
transition

Error “do” activity


entry/printf(“error!”)

do/while (true) alarm.ring();

19
Basic UML State Model Syntax

“top” state
State
Initial
pseudostate Top
Trigger

Ready
Transition

stop /ctr = 0

Done
Final
Action
state
stop

20
Guards

Boolean predicates to indicate Conditional
execution of transitions
bid [value < 100] /reject

bid [value >= 200] /sell


Selling Happy

bid [(value >= 100) & (value < 200)] /sell

Unhappy
21
Eliminating Duplicated Transitions

Duplicate transitions exist er
when some transition can ro
r
happen from every state:
 “error” quit Quit
 “quit” t
ab or
 “abort”


These duplicates can be
combined into a single
transition:
 A transition from a
superstate holds for Quit
all of its substates!

22
23
Hierarchical State Machines

Obtained by replacing transition from every
substate by a single transition from
superstate…
LampOff
flash/ LampFlashing
entry/lamp.off()
FlashOn

off/ entry/lamp.on()

1sec/
1sec/
on/ on/
FlashOff
on/
LampOn entry/lamp.off()
entry/lamp.on()
24
Group Transitions

Higher-level transitions
Default transition to
the initial pseudostate

LampOff flash/ LampFlashing


LampFlashing
entry/lamp.off()
FlashOn
off/ entry/lamp.on()

1sec/
1sec/
on/
FlashOff
LampOn
on/
entry/lamp.off()
entry/lamp.on()

Group transition
25
Completion Transitions

Triggered by a completion event:
 Generated automatically when an immediately
nested state machine terminates.

completion
Committing transition (no trigger)
Phase1

CommitDone
Phase2

26
A Heart Monitor Application: Convert to
Hierarchical State Machine

Start Up
Problem
Switch Detected
ON

Switch
OFF
Startup
Complet
Off e Alarm

Switc Problem
h OFF Detected

Operation
al 27
Heart
Monitor
Revisite ON
d Start Up
Transition from
Super state
Switc
h
ON
Startup Problem
Complet Detected
Off Switc
e Alarm
h OFF

Operation
al

28
Complete Diagram for Heart Monitor
Application Quiz:
The number
of states and Convert to
StartUp
transitions
have grown Battery AND-
quickly State…
Start Up Mains
Alarm Battery

Off Alarm Mains

Operational
Why do the Battery
states and
transitions
grow fast? Operational
mains
29
Heart Monitor as Concurrent State
Machine
Monitoring Subsystem

Running

Switch on
Startup
Problem
detected
Off Startup Alarm
Switch off Complete

Operational Dotted line


separates
concurrent state
machines

Power Subsystem

Mains on
Battery Mains
Mains off
30
Introducing Hierarchy
f
g h i j
A B C D E
k k k k
k
m Z
super-state S

f
A g B h C i D j E

k
m
Z sub-states
31
Dialling
Basic
Start Composit
entry/start dial tone
exit/stop dial tone
e State:
OR state
digit(n)

Encode

32
Composite State: AND State

Composite states can have:
– concurrent substates -and- relationship
• substate separated from others by dotted
line
– disjoint substates -or- relationship
• transitions between substates
Overhead Projector

On Desk Light Off

On Floor Light On 33
Exercise 1: Develop State Machine Model


In a chess game:
 Black and white sides take turn to
play.


The game ends anytime when:
 Either there is a checkmate, or

 There is a stalemate.
34
Chess

White’s
turn
stale
mate

blac whit
k e
mov mov e
m at
es eck
es ch
Black’s
turn
35
Handling Interrupted States

Sometimes it is necessary to interrupt a
complicated procedure:
 And then resume exactly from where you stopped


Consider installing a program on your computer
 “Out of memory: please delete some files and hit continue”


In many situations a normal course of
processing is interrupted and then resumed
 How can this be handled in a nested state diagram?

36
History

Transit to a higher level state and then return
to resume the activity at which transited.
Diagnosing
suspend/
Diagnostic1 Diagnostic2

Step11 Step21

resume/ Step12 Step22


H*

37
Orthogonality

Multiple simultaneous perspectives on
the same entity.
age financialStatus

Child
Poor
Adult

Rich
Retiree

38
Orthogonal Regions

Combine multiple simultaneous
descriptions
age
financialStatus

Child
Poor
Adult
age financialStatus

Child Rich
Retiree
Poor
Adult

Retiree Rich
39
Orthogonal Regions - Semantics

All mutually orthogonal regions detect the
same events and respond to them
“simultaneously”
 Usually
Person reduces to interleaving of some kind.
legalStatus financialStatus

LawAbiding Poor

robBank/ robBank/

Outlaw Rich
40
Common Misuse of Orthogonality

Using regions to model independent objects
Person1 Person2

Person1 Person2
Child Child

Adult Adult

Retiree Retiree

41

You might also like