23
Ch5: Software Specification

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

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

Ch5: Software Specification

2

Finite State Machines (FSMs)

Consist of:

Use of FSMs:

3

FSMs (contd..)

a a

b

bc

q

q

q

q

1

20

3

Graphically, -

4

FSM example: A lamp

On Off

Push switch

Push switch

5

FSM example: A plant control system

On Off

High-pressure alarm

High-temperature alarm

Restart

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

7

Classes of FSMs

Deterministic/non deterministic:

FSMs as recognizers:

FSMs as transducers:

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

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?

10

Limitations of FSMs

Finite memory

State explosion

11

Limitations of FSMs (contd..)

Producer

p1

c2

Storage

1

produce

deposit

get

consume

deposit

get get

deposit

p2

Consumer

c1

20

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:

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

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

15

UML diagrams

Use case diagrams Sequence diagrams Collaboration diagrams

16

Use case diagrams

Show all the possible functionality

Do not describe any details Used during requirements analysis

17

Components of use case diagrams

Actors

18

Components of use case diagrams (contd..)

Use Cases

19

Components of use case diagrams (contd..)

Association

20

Uses of use case diagrams

Determining features (requirements):

Communicating with clients:

Generating test cases:

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:

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.

23

Use case diagrams – Example #1

CompileList

Make Reservation

Cancel Reservation

External Flight Database Customer

Use case

Actor

Communication

Reservation System

CreditCard System

SecurityPersonnel