Design
Design
Main issues:
decompose system into parts
many attempts to measure the results
design as product design as process
Overview
Introduction
Design principles
Design methods
Conclusion
Introduction
Design principles
Design methods
Conclusion
Abstraction
Modularity, coupling and cohesion
Information hiding
Limit complexity
Hierarchical structure
abstraction subproblems
time
simpler data
general structure
data structures
coincidental cohesion
logical cohesion
temporal cohesion
procedural cohesion
communicational cohesion
sequential cohesion
functional cohesion
content coupling
common coupling
external coupling
control coupling
stamp coupling
data coupling
nowadays:
modules may pass complex data structures
modules may allow some modules access to their data, and
deny nit to others (so there are many levels of visibility)
coupling need not be commutative (AQ may be data coupled
to B, while B is control coupled to A)
simpler communication
simpler correctness proofs
changes influence other modules less often
reusability increases
comprehensibility improves
#include <stdio.h>
#define NULL 0
main ()
{
int i;
for (i=0;i<10;i++) printf(%d”,i);
}
two classes:
measures based on size
measures based on structure
public 1
sort() 1
int 4
[] 7
{} 4
for {;;} 2
if () 1
= 5
< 2
… …
n1 = 17 N1 = 39
x 9
length 2
i 7
j 6
save 2
0 1
1 2
n2 = 7 N2 = 29
size of vocabulary: n = n1 + n2
program length: N = N1 + N2
volume: V = N log2n
level of abstraction: L = V*/ V
approximation: L’ = (2/n1)(n2/N2)
programming effort: E = V/L
estimated programming time: T ’ = E/18
estimate of N: N ’ = n1log2n2 : n2log2n2
for this example: N = 68, N ’ = 89, L = .015, L’ = .028
critique:
explanations are not convincing
results from cognitive psychology used wrongly
is aimed at coding phase only; assumes this is an
uninterrupted concentrated activity
different definitions of “operand” and “operator”
based on
control structures
data structures
or both
example complexity measure based on data
structures: average number of instructions
between successive references to a variable
best known measure is based on the control
structure: McCabe’s cyclomatic complexity
Example program
2
3
public static void sort(int x []) {
for (int i=0; i < x.length-1; i++) {
4
for (int j=i+1; j < x.length; j++) {
if (x[i] > x[j]) {
5
int save=x[i];
x[i]=x[j]; x[j]=save
11
} 6
}
} 7
}
8
10
Cyclomatic complexity
2
11
CV = e - n + p + 1 (4) 6
10
e-n+p+1 = 13-13+3+1 = 4
e-n+p+1 = e-n+2p = 4
e-n+2p = 6
chaos hierarchy
strict
hierarchy tree
} size
# nodes
# edges
width
height
hierarchy
strict
hierarchy tree
chunks
mostly, c(i) = 1
R1
M2
M1
M3
Introduction
Design principles
Design methods
Conclusion
Functional decomposition
OO is gOOd, isn’t it
bottom-up top-down
external entities
processes
data flows
data stores
direction request
library
management client
system
report ack’ment
client management
request
report direction
log data
prelim. prelim.
acknowledgement
doc doc
return
borrow
request
request log data
catalog adm.
check OK
client process
data request
borrow return
not OK request request
Conventions:
[ ]: include one of the enclosed options
|: separates options
+: AND
(): enclosed items are optional
A B D E F G
C H K
Do job
C D E F
A B G H
A A A
B C D B* Bo Co Do
input output
line * line *
until EOF
loop
read line
process line
write line
endloop
input file
article
mutation
addition removal
output
heading body
net mutation
program
heading contents
do mutation
do addition do removal
write read
mutation mutation
JSP:
Problem structure data structure
program structure
software
library
system
station
customer
transaction
book
library employee
identification card
client
bar code reader
book’s code
Analysis
object model
interface model
Design
object interaction
visibility graphs
graphs
problem-oriented product-oriented
I II
conceptual ER modeling Structured design
Structured analysis
III IV
formal JSD Functional decomposition
VDM JSP
Designer’s experience
Available tools
Development philosophy
Context:
Client needs services from other component, direct access
may not be the best approach
Problem:
We do not want hard-code access
Solution:
Communication via a representative, the Proxy
Context:
User interface that must be flexible or provides functionality
beyond handling of user functions
Problem:
Well-structured solution for mapping interface to internal
functionality. All ‘extras’ are separate from the interface
Solution:
A separate component, the Command Processor, takes care
of all commands Actual execution of the command is
delegated
Introduction
Design principles
Design methods
Conclusion