Professional Documents
Culture Documents
Chapter 5
Chapter 5
Ch. 5
Outline
Discussion of the term "specification"
Types of specifications
operational
Data Flow Diagrams
(Some) UML diagrams
Finite State Machines
descriptive
Entity Relationship Diagrams
Ch. 5
Specification
Discussion of the term "specification"
What does software specification mean?
Do we need that?
Ch. 5
Ch. 5
Specification
A broad term that means definition
Used at different stages of software
development for different purposes
Generally, a statement of agreement
(contract) between
producer and consumer of a service
implementer and user
Uses of specification
Statement of user requirements
major failures occur because of
misunderstandings between the
producer and the user
"The hardest single part of building a
software system is deciding precisely
what to build" (F. Brooks)
Ch. 5
Specification qualities
Precise, clear, unambiguous
Consistent
Complete
Incremental
Ch. 5
Clear, unambiguous,
understandable
Example: specification fragment for a
word-processor. A select command.
Selectingistheprocessofdesignating
areasofthedocumentthatyouwanttowork
on.Mosteditingandformattingactions
requiretwosteps:firstyouselectwhatyou
wanttoworkon,suchastextorgraphics;
thenyouinitiatetheappropriateaction.
Ch. 5
10
Clear, unambiguous,
understandable
Example: specification fragment for a
word-processor. A select command.
What does area mean? Can an area be a collection of
sequence of scattered characters?
Ch. 5
11
Ch. 5
12
Ch. 5
13
Consistent
Example: specification fragment for a
word-processor
Thewholetextshouldbekeptinlines
ofequal length.Thelengthisspecified
bytheuser.Unlesstheusergivesan
explicithyphenationcommand,
acarriagereturnshouldoccuronly
attheendofaword.
Ch. 5
14
Consistent
Example: specification fragment for a
word-processor
Ch. 5
15
Complete
Internal completeness
the specification must define any new
concept or terminology that it uses
glossary helpful for this purpose
Ch. 5
16
Incremental
Referring to the specification
process
start from a sketchy document and
progressively add details
17
Classification of
specification styles
Informal, semi-formal, formal
Operational
Behavior specification in terms of
some abstract machine
Descriptive
Behavior described in terms of
properties
Ch. 5
18
Example 1
Specification of a geometric figure E:
E can be drawn as follows:
1. Select two points P1 and P2 on a plane
2. Get a string of a certain length and fix its ends
to P1 and P2
3. Position a pencil as shown in next figure
4. Move the pen clockwise, keeping the string
tightly stretched, until you reach the point where
you started drawing
this is an operational specification
Ch. 5
19
P1
P
2
20
A descriptive specification
Geometric figure E is described by
the following equation
ax2 + by2 + c = 0
where a, b, and c are suitable
constants
Ch. 5
21
Another example
OP
22
How to verify a
specification?
Observe dynamic behavior of
specified system (simulation,
prototyping, testing specs)
Analyze properties of the specified
system
Analogy with traditional engineering
physical model of a bridge
mathematical model of a bridge
Ch. 5
23
Ch. 5
24
Graphical notation
bubbles represent functions
arcs represent data flows
open boxes represent persistent
store
closed boxes represent I/O
interaction
The function symbol
25
Example
specifies evaluation of
(a + b) * (c + a * d)
Ch. 5
26
Output
1
2
Input n
information
...
system
Ch. 5
...
Output
Output
1
2
m
27
H
I
A3
J
A4
A1
K
A2
K2
S
N
A6
P
A5
B2
K3
K1
T
B1
Ag
A7
B3
B4
K4
Ch. 5
28
A library system
User request consisting of title, name
of author
Access to the shelves that contain the
book.
List of authors
List of titles
Users name
Ch. 5
29
A library example
Book
Book request
by the user
Shelves
Author
Book
List of Authors
Get a book
Title
Book
reception
Book title;
user name
List of titles
Title
Search by
topics
List of topics
Topic
Topic
Topic request
by the user
List of titles
referring to the topic
Ch. 5
Display of
the list of titles
30
Refinement of
Get a book
Book
Shelves
Author
Get
the book
Book
List of Authors
<shelf#, book#>
Find
book
position
Title
Book
reception
List of titles
Title and author
of requested book;
name of the user
Book title;
user name
Book request
by the user
Ch. 5
31
An evaluation of DFDs
Semantics of the symbols is
determined only by the identifiers
provided (find book position, +)
Access to the shelves that contain the
book.
List of authors
List of titles
Users name
Ch. 5
32
Ch. 5
33
34
A
E
B
D
F
Ch. 5
35
Possible interpretations:
(a) A produces datum, waits until B consumes it
(b) B can read the datum many times without
consuming it
(c) a pipe is inserted between A and B. A denotes
computing time spent by employees in their work
and B denotes computing a payroll.
Ch. 5
36
Formalization/extensions
There have been attempts to formalize
DFDs
There have been attempts to extend
DFDs (e.g.,
for real-time systems)
d1
Trigger
d2
.
.
.
dn
Ch. 5
37
return
book
librarian
customer
library
update
Ch. 5
38
Librarian
Catalogue
membercard+
book request
membership
OK
bookrequest
time
bookavailable
bookborrowed
Ch. 5
39
Customer
3: book request
Librarian
5: book borrowed
Catalogue
4: book available
Ch. 5
40
a
b
q0
c
q2
b
q3
Ch. 5
41
Example: a lamp
Push switch
Of
On
Push switch
Ch. 5
42
Another example:
a plant control system
High-pressure alarm
High-temperature alarm
On
Off
Restart
Ch. 5
43
A refinement
Pressure signal
Normal
Pressure
Pressure
action
ac tion
Suc cessful
recovery
Temperature signal
Unsucc essful
recovery
Normal
Of
Off
Succ essful
recovery
Temperature signal
Unsuccessful
recovery
Temperature
ac tion
Ch. 5
Pressure signal
44
Classes of FSMs
Deterministic/nondeterministic
FSMs as recognizers
introduce final states
FSMs as transducers
introduce set of outputs
...
Ch. 5
45
FSMs as recognizers
q1
q2
q3
q4
b
q0
qf
e
q5
q6
qf is a final state
Ch. 5
46
FSMs as recognizers
<letter>
<digit>
q
<letter>
q1
<letter>
Legend:
<letter>
<digit>
q2
<digit>
47
Limitations
Finite memory
State explosion
Given a number of FSMs with k1, k2,
kn states, their composition is a FSM
with k1 * k2 * * kn. This growth is
exponential with the number of FSMs,
not linear (we would like it to be k1 +
k2 + + kn )
Ch. 5
48
Producer
p1
p2
deposit
get
Consumer
c1
c2
consume
deposit
Storage
0
deposit
1
get
Ch. 5
get
49
write
<1, p ,c >
1 1
consume
produce
consume
produce
<0, p ,c >
2 1
<2, p1 ,c >
1
produce
<1, p ,c>
2 1
<2, p ,c >
2 1
read
<0, p ,c >
1 2
<1, p ,c >
1 2
<2, p ,c >
1 2
read
produce
consume
<0, p2 , c2 >
read
write
produce
consume
read
write
<1, p ,c2>
2
Ch. 5
produce
consume
<2, p ,c2>
2
50
Declarative specifications
ER diagrams: semiformal
specs
Logic specifications
Algebraic specifications
Ch. 5
51
ER diagrams
Often used as a complement to
DFD to describe conceptual data
models
Based on entities, relationships,
attributes
They are the ancestors of class
diagrams in UML
Ch. 5
52
Example
NAM E
AGE
STUDENT
SEX
ENROLLED_IN
SUBJECT
CLASS
COURSE_ID
M AX_ENROLLM ENT
Ch. 5
53
Relations
Relations can be partial
They can be annotated to define
one to one
one to many
many to one
many to many A
Ch. 5
54
Data
Director
HeadOf
Department
Participate
Assigned
Project
Employee
Ch. 5
55
Ch. 5
56
Ch. 5
57
Sequential decomposition
--chemical plant control example-Normal
AnomalyDetection
RecoverySuccess
Recovery
Press
Recovery
Identification
Temp
Done
Pressure
Action
Done
Temperature
Action
Ch. 5
RecoveryFailure
58
Parallel decomposition
Idle
start
stop
ConcurrentWork
write
P1
write
read
produce
read
read
write
P2
Producer
C1
Buffer
Ch. 5
consume
C2
Consumer
59
Push(item)
NotEmpty
y
Pop[stack contains 1 item]
Push(item)
Ch. 5
60
Ch. 5
61
62
Conclusions (1)
Specifications describe
what the users need from a system (requirements
specification)
the design of a software system (design and
architecture specification)
the features offered by a system (functional
specification)
the performance characteristics of a system
(performance specification)
the external behavior of a module (module interface
specification)
the internal structure of a module (internal structural
specification)
Ch. 5
63
Conclusions (2)
Descriptions are given via suitable
notations
There is no ideal notation
64