Top Banner
Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003
53
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: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Chapter 5: Specification

Yuanfang Cai

CS751 Jan 29, 2003

Page 2: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Overview

Definition5.1 The Uses of Specification5.2 Specification Qualities5.3 Classification of Specification Styles5.4 Verification of Specification5.5 Operational Specifications5.6 Descriptive Specifications5.7 Building and Using Specifications in Practice

Page 3: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Overview

Definition5.1 The Uses of Specification5.2 Specification Qualities5.3 Classification of Specification Styles5.4 Verification of Specification5.5 Operational Specifications5.6 Descriptive Specifications5.7 Building and Using Specifications in Practice

Page 4: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Overview

Definition5.1 The Uses of Specification5.2 Specification Qualities5.3 Classification of Specification Styles5.4 Verification of Specification5.5 Operational Specifications

5.5.1 Data Flow Diagram (DFD): Function5.5.2 Unified Modeling Language (UML): Behavior5.5.3 Finite State Machine (FSM): Control Flow5.5.4 Petri Nets: Asynchronous Systems

5.6 Descriptive Specifications5.7 Building and Using Specifications in Practice

Page 5: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Overview

Definition5.1 The Uses of Specification5.2 Specification Qualities5.3 Classification of Specification Styles5.4 Verification of Specification5.5 Operational Specifications5.6 Descriptive Specifications

5.6.1 Entity Relationship Diagrams5.6.2 Logic Specification5.6.3 Algebraic Specifications

5.7 Building and Using Specifications in Practice

Page 6: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Definition

The statement of an agreement between a producer of a service and the consumer of the service or between an implementer and a user

Requirement specification

Design specification

Module specification

Requirements, Specification and Design

Page 7: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Definition

The statement of an agreement between a producer of a service and the consumer of the service or between an implementer and a user

Requirement specification Between end user and the system architect/developer

Design specification

Module specification

Requirements, Specification and Design

Page 8: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Definition

The statement of an agreement between a producer of a service and the consumer of the service or between an implementer and a user

Requirement specification Between end user and the system architect/developer

Design specification Between the architect and the implementers

Module specification

Requirements, Specification and Design

Page 9: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Definition

The statement of an agreement between a producer of a service and the consumer of the service or between an implementer and a user

Requirement specification Between end user and the system architect/developer

Design specification Between the architect and the implementers

Module specification Between the implementer and the user of a module

Requirements, Specification and Design

Page 10: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.1 The use of Specifications

A statement of user requirement A statement of interface between the

machine and the controlled environment A statement of requirements for the

implementation A reference point during product

maintenance.

Page 11: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.2 Specification Quality

Clear, unambiguous and understandable Consistency Complete

Internally complete Externally complete

Page 12: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.3 Classification of Specification Styles

Formal, informal and Semiformal Specifications

Operational and descriptive specifications Operational specifications: desired behavior Descriptive specifications: desired properties

Page 13: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.4 Verification of Specifications

Dynamic analysis Static analysis Formalism and verification

Simulation Prototype

Verify all three aspects: Functional Consistency completeness

Page 14: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5 Operational Specifications

5.5.1 Data Flow diagrams Features Example limitations

5.5.2 UML Diagram for Specifying Behaviors

5.5.3 Finite State Machine: Describing Control Flow

5.5.4 Pretri Nets: Specifying Asynchronous Systems

Page 15: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.1 Data Flow Diagram: Specifying Functions of Information Systems

Features Describe systems as collections of functions that

manipulate data Can be expressed by means of graphical notation Elements:

Input device symbolFunction symbol

Data flowOutput device symbol

Data store symbol

Page 16: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

a+ * +

*

b d c

5.5.1 DFD Example

(a + b) * ( c + a * d)

Page 17: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.1 DFD limitations

The semantics of the symbol is specified only by the identifiers chosen by the user.

Control aspects are not defined by the model

B D

E

C

F

A

Page 18: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.1 DFD Limitations

The semantics of the symbol is specified only by the identifiers chosen by the user.

Control aspects are not defined by the model

B D

E

C

F

A

Page 19: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.1 DFD Limitations

The semantics of the symbol is specified only by the identifiers chosen by the user.

Control aspects are not defined by the model

B D

E

C

F

A

Page 20: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5 Operational Specifications

5.5.1 Data Flow diagrams

5.5.2 UML Diagram for Specifying Behaviors Features Example Limitations

5.5.3 Finite State Machine: Describing Control Flow

5.5.4 Pretri Nets: Specifying Asynchronous Systems

Page 21: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5 Operational Specifications

5.5.1 Data Flow diagrams

5.5.2 UML Diagram for Specifying Behaviors

5.5.3 Finite State Machine: Describing Control Flow Definiation Features Example Limitations

5.5.4 Pretri Nets: Specifying Asynchronous Systems

Page 22: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.3 Finite State Machines: Describing Control Flow

DefinitionA finite automata is a 5-tuple (Q, , , q0, F),

where1. Q is a finite set called the states,2. is a finite set called the alphabet (inputs),3. : Q Q is the transition function,

4. q0 Q is the start state, and 5. F Q is the set of accept states (final states).

Page 23: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.3 Finite State Machines: Describing Control Flow

Features Formal notation Suitable for describing systems that can be in a

finite set of states and that can go from one state into another as a consequence of some event, modeled by an input symbol.

Widely used: specification of control systems, compilation, pattern matching, etc.

Page 24: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.3 Finite State Machines: Describing Control Flow

Example

On Off

Push switch

Push switch

Page 25: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.3 Finite State Machines: Describing Control Flow

Example: Chemical plant

On Off

High-pressure alarm

Restart

High-temperature alarm

Page 26: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

NormalOff

PressureRecovery

TemperatureRecovery

Pressure signal Temperature signal

Temperature signal Pressure signal

Successful

recovery

Unsuccessful

recovery

Successful

recovery

Unsuccessful

recovery

5.5.3 Finite State Machines: Describing Control Flow

Example: Chemical plant

Page 27: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.3 Finite State Machines: Describing Control Flow

Limitations Finite states: need assistance such as natural language or

accompanied by action descriptions, like:Cooling_effort := k * (present_temperature – standard temperature)

Can’t describe concurrent, asynchronous systems.

P1 P2 C1 C2

0 1 2

write

produce read

consume

write write

readread

empty full

Page 28: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

consume

consume

Produce

Produce

<0,p1,c1>

<0,p2,c1>

<0,p1,c2>

<0,p2,c2>

consume

consume

Produce

Produce

<1,p1,c1>

<1,p2,c1>

<1,p1,c2>

<1,p2,c2>

consume

consume

Produce

Produce

<2,p1,c1>

<0,p2,c1>

<2,p1,c2>

<2,p2,c2>

writewrite

read read

write

read read

5.5.3 FSM: Describing Control Flow Example continued: the Cartesian Product of the component state sets:

Page 29: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.3 Finite State Machines: Describing Control Flow

Limitations: The cardinality of the state space grows dramatically:

if we have n subsystems, each with ki states, the resulting system has a cardinality of k1*k2*…Kn

FSM are essentially a synchronous model: at any time, a global state of the system must be defined and a single transition must occur.

Page 30: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5 Operational Specifications

5.5.1 Data Flow diagrams

5.5.2 UML Diagram for Specifying Behaviors

5.5.3 Finite State Machine: Describing Control Flow

5.5.4 Pretri Nets: Specifying Asynchronous Systems Definition Example Features Limitations

Page 31: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.4 Petri Nets: Specifying Asynchronous System

DefinitionA Petri Net is a quadruple (P, T, F, W), where1. P is the finite set of places;2. T is a finite set of transitions; 3. P T ;4. F { P T} { T P} is the flow relation; and5. W: F N – {0} is the weight function, which

associates a nonzero natural value to each element of F. If no weight value is explicitly associated with a flow element, the default value 1 is assumed for the function

Page 32: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.4 Petri Nets: Specifying Asynchronous System

Example:

write

produce

p1 p2

Place

Token

Transition

p2 is the input place of transition write

p1 is the output place of transition write

Produce is the enabled, so transition produce may fire

Page 33: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.4 Petri Nets: Specifying Asynchronous System

Example:

write

produce

p1 p2

Place

Token

Transition

p2 is the input place of transition write

p1 is the output place of transition write

Produce is the enabled, so transition produce may fire

2

Page 34: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.4 Petri Nets: Specifying Asynchronous System

Example: After produce fired

write

produce

p1 p2

Place

Token

Transition

p2 is the input place of transition write

p1 is the output place of transition write

Now, write is the enabled, so transition write may fire

2

Page 35: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

write

produce

p1 p2

consume

read

c1 c2

read

write

0 1

read

write

2

5.5.4 PN: Specifying Asynchronous System Example: producer and consumer

Page 36: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

consume

c1 c2

producep1 p2

read

write

0 1

read

write

2

5.5.4 PN: Specifying Asynchronous System

Example continued:

producer and consumer:

Now the system is at the state <0, p1, c1>

Page 37: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

consume

c1 c2

producep1 p2

read

write

0 1

read

write

2

5.5.4 PN: Specifying Asynchronous System

Example continued:

producer and consumer:

Now the system is at the state <0, p2, c1>

Page 38: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

consume

c1 c2

producep1 p2

read

write

0 1

read

write

2

5.5.4 PN: Specifying Asynchronous System

Example continued:

producer and consumer:

Now the system is at the state <1, p2, c1>

Page 39: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.5.4 Petri Nets: Specifying Asynchronous System

FeaturesGood at describing concurrent and asynchronous

system

Limitations Tokens are anonymous Can’t specify a selection policy Can’t resolve deadlock or starving…

Page 40: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.6 Descriptive Specifications

5.6.1 Entity Relationship (ER) Diagrams

A semiformal notation

5.6.2 Logic Specification

5.6.3 Algebraic Specifications

Page 41: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.6.1 Entity Relationship Diagrams

STUDENT

CLASS

AGE

SEX

NAME

ENROLLED_IN

SUBJECT

COURSE_ID

MAX_ENROLLMENT

Entities: a collection of items that

share common properties

Relations: A set of pairs <a, b>, where

a is an element of STUDENT and b is an element of CLASS

Attribute:

Page 42: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

5.6.1 Entity Relationship Diagrams

Relation Attributes:

A BR

A BR

A BR

A BR

A R B is one to one

A R B is one to many

A R B is many to one

A R B is many to many

Page 43: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Unified Modeling Language

A general-purpose visual modeling language that is used to specify, visualize, construct and document the artifacts of a software system.

Static Structure (Descriptive) Dynamic behavior (Operational)

Page 44: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Unified Modeling Language

Static Structure (Descriptive) Static view: class diagram User Case View Physical Views

Implementation view Deployment view

Dynamic behavior (Operational) Interaction view

Sequence diagram Collaboration diagram

State machine view Activity view

Page 45: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Unified Modeling Language

Static Structure (Operational) Static View: class diagram User Case View Physical Views

Implementation view Deployment view

Dynamic behavior (Descriptive) Interaction view

Sequence diagram Collaboration diagram

State machine view Activity view

Page 46: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

CustomerName: String

Phone: StringAdd(name,phone)

Reservation

Date: Date

Subscription Series

Series: integer

Individual

Reservation

Ticket

Available: Boolean

Sell (c. Customer)

Exchange()

Show

Name: String

Performance

Date: Date

Time: TimeOfDay

Seat: Sting

1

*

1*

1

1..*

Class

attributes

class-scope operation

association

generalization

multiplicities

Class Diagram:

qualifier

0..1

3..6

0..1

1

Page 47: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Kiosk

buy tickets

buy subscription

makecharges

surveysales

relationship

Use case

<<include>>

<<include>>

Clerk

Credit card service

Supervisor

system actor Use Case Diagram:

Page 48: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Unified Modeling Language

Static Structure (Operational) Static View: class diagram User Case View Physical Views

Implementation view Deployment view

Dynamic behavior (Descriptive) Interaction view

Sequence diagram Collaboration diagram

State machine view Activity view

Page 49: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Kiosk box office credit card service

message

Request (count, performance)

Show availability (seat-list)

Select(seats)

Demand payment(cost)

Insert card(card number)

Print tickets (performance, seats)

Eject card

charge(card number,cost))

authorized

lifeline (active)

Active object

Sequence Diagram

Page 50: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Kiosk

ticketseller

message

active object

performanceGuide

Db: performanceDB

link

multi object

Db: performanceDB

2: db := findDB(performance)

<<local>>dbtransient link

passive object

1:request (count, performance)

4: offer(seat-list)

5:buy(seats)

8:confirm (seats, cost)

3: seat-list := lock(count) 6: claim (seats) 7: unlock(seat-list)

Collaboration

Diagram:

Page 51: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Initial state

Available Locked Sold

state

transition

Trigger event

Assign to subscription

Time out

lock

unlock

exchange

buy

State chart Diagram

Page 52: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

activity

Pick show

schedule show

publicize show

Buy scripts and music

Hireartists

Build sets

Design lighting

Makecostumes

Sell tickets rehearse

Dress rehearsal

perform

Completion transition

join

fork

Activity Diagram

Page 53: Chapter 5: Specification Yuanfang Cai CS751 Jan 29, 2003.

Questions?