Top Banner
Ch5: Software Specification
23

Ch5: Software Specification. 1 Finite State Machines (FSMs) Consist of: Use of FSMs:

Dec 22, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

Ch5: Software Specification

Page 2: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

2

Finite State Machines (FSMs)

Consist of:

Use of FSMs:

Page 3: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

3

FSMs (contd..)

a a

b

bc

q

q

q

q

1

20

3

Graphically, -

Page 4: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

4

FSM example: A lamp

On Off

Push switch

Push switch

Page 5: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

5

FSM example: A plant control system

On Off

High-pressure alarm

High-temperature alarm

Restart

Page 6: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

6

FSM example: A refinement of plant control system

Pressure signal Temperature signal

Successful recovery

Unsuccessful recovery

OffNormal

Pressure action

OffNormal

Pressure action

Temperature signalTemperature action

Successful recovery

Unsuccessful recovery

Pressure signal

Page 7: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

7

Classes of FSMs

Deterministic/non deterministic:

FSMs as recognizers:

FSMs as transducers:

Page 8: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

8

FSMs as recognizers

q

q q q q

q q

q

b

e g i

n

e

n

d

0

1 2 3 4

5 6

f

Page 9: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

9

FSMs as recognizers (contd..)

q1 q2 q3 q4

q5 q6 q7 q8

qfq0

brr e a

d

h

wr

i

o

te

What are the strings accepted by this FSM?

Page 10: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

10

Limitations of FSMs

Finite memory

State explosion

Page 11: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

11

Limitations of FSMs (contd..)

Producer

p1

c2

Storage

1

produce

deposit

get

consume

deposit

get get

deposit

p2

Consumer

c1

20

Page 12: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

12

Limitations of FSMs (contd..)

In the composite FSM, a state is given by a 3-tuple:

State of the storage:State of the producer:State of the consumer:

Initial state:Total number of states in the composite FSM:

Page 13: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

13

Limitations of FSM (contd..)

The resulting FSM

<0, p ,c >

<0, p ,c >

consume

produce

consume

produce

consume

produce

consume

produce

produce produce

consume consume

write

read

write

read

read

write read

write

1

1 2

<0, p , c >

1

2 2

<1, p ,c >

<0, p ,c >

1 1

<1, p ,c>

<1, p ,c >

<1, p ,c >

2 1

1 2

1

2

2 2 <2, p ,c > 2 2

<2, p ,c > 1 2

<2, p ,c > 2 1

<2, p ,c > 1 1

Page 14: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

14

FSMs summary

Simple and widely used:

Most software can be modeled using FSMs FSMs may become complex:

FSMs can be composed to create new FSMs

Page 15: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

15

UML diagrams

Use case diagrams Sequence diagrams Collaboration diagrams

Page 16: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

16

Use case diagrams

Show all the possible functionality

Do not describe any details Used during requirements analysis

Page 17: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

17

Components of use case diagrams

Actors

Page 18: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

18

Components of use case diagrams (contd..)

Use Cases

Page 19: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

19

Components of use case diagrams (contd..)

Association

Page 20: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

20

Uses of use case diagrams

Determining features (requirements):

Communicating with clients:

Generating test cases:

Page 21: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

21

Suggestions for designing good use cases

Choose a good name:

Show a complete and completable behavior:

Show inverse use cases if applicable:

Limit a use case to one behavior/function:

Write the use cases from the actor’s point of view:

Page 22: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

22

Use case diagrams – Example #1

Consider an airline reservation system. A customer can use this systemto either make or cancel a reservation. The system obtains flight information such as the availability of the flights from an external flight database system. During the process of making a reservation, the system may be required to obtain credit card authorization from the credit card system. Every day, the system compiles a list of passengers with reservations on each flight is forwarded to the security personnel.

Page 23: Ch5: Software Specification. 1 Finite State Machines (FSMs)  Consist of:  Use of FSMs:

23

Use case diagrams – Example #1

CompileList

Make Reservation

Cancel Reservation

External Flight Database Customer

Use case

Actor

Communication

Reservation System

CreditCard System

SecurityPersonnel