Академический Документы
Профессиональный Документы
Культура Документы
Architecture
Dr. Vu Thi Huong Giang
@2012-2013
Covered topics
Divide and conquer strategy
Modularization techniques
Architecture
1.
2.
3.
4.
Introduction
Decomposition
Composition
Step refinement
4
Introduction
Divide: decompose
problems into subproblems
Conquer: solve subproblems (hopefully
easier)
Assemble : compose the
complete solution from
the sub-solutions
We decompose
However, we may
choose where we begin:
Stepwise Refinement
(top-down)
Assemblage and
Composition (bottom-up)
Design from the middle
(middle-out)
1. Decomposition
The process by which a complex problem or
system is broken down into parts that are easier
to conceive, understand, program, and maintain
Problem
Sub - P
Sub - P
Sub - P
Sub - P
Sub - P
Sub - P
sequence
add boiling
water
wait
repetition
pour spoon tea
into pot
selection
fetch green
tea
fetch black
tea
8
Transfer
Deposit
Withdraw
9
10
sequence
condition
add boiling
water
wait
repetition
condition
pour spoon tea
into pot
selection
condition
fetch green
tea
fetch black
tea
11
Transfer
Deposit
Withdraw
12
Case 2: Structure-oriented:
What are the components of the system and their relations
13
action
Put tea in pot
add boiling
water
wait
Pot
Data
Cup
14
Transfer
Deposit
Withdraw
15
2. Composition: bottom-up
Given an abstract machine implementing the
partial solution, stepwise construction includes:
assemble more complex operations of a higher-level
abstract machine
assemble the more complex data structures
Good:
always realistic
a running partial solution
Bad:
Design might become clumsy since global picture was
not taken into account
16
17
Bad:
we might never reach a realization
often warehouse solutions are developed
18
Decomposition tree
Stepwise refinement process may be depicted by
a decomposition tree
root labeled by name of top problem
subproblem nodes labeled as children of parent node
corresponding to problem
children from left to right represent sequential order of
execution
if and while nodes denoted by suitable decoration
19
Example
Produce tea
add boiling
water
wait
C
pour spoon tea
into pot
C1
fetch green
tea
not C1
fetch black
tea
20
Transfer
Deposit
Withdraw
21
II. MODULARIZATION
TECHNIQUES
1. Module
2. Relations between modules
3. Specific techniques for design for change
22
23
Questions
How to define the
structure of a
modular system?
What are the
desirable
properties of that
structure?
M1
M2
Mn-1
Mn
System
24
design
decision
design
decision
1
design
decision
design
decision
M2
design
decisionn-1
design
decision
design
decision
n
design
decision
System
25
Client
Resources to be exported:
types; variables, attributes,
functions, events, exceptions,
etc.
interface Bicycle {
void changeCadence (int newValue);
void changeGear(int newValue);
void speedUp(int increment);
void applyBrakes(int decrement);
}
Module
Interface
Secret
Module
Implementation of
exported resources
class Bike implements Bicycle {
}
class Motor-Bike implements Bicycle {
}
26
Interface
Client
Module
Interface
Secret
Module
Information hiding
Client
Module
Interface
Secret
Module
II. MODULARIZATION
TECHNIQUES
1. Module
2. Relations between modules
3. Specific techniques for design for change
29
2.1. Definition
Let S be a set of
modules
S = {M1, M2, . ., Mn}
A binary relation r
on S is a subset of
SxS
If Mi and Mj S,
a pair <Mi, Mj> r
can be written as
Mi r Mj
M1
M2
Mn-1
Mn
System
30
2.2. Classification
delegates-to (delegation)
is-a (inheritance)
has-a (aggregation)
is-component-of,
comprises (composition)
accesses-a (access
relation)
is-privileged-to, owns-a
(security)
calls
is-called-by
relies-on (uses)
M1
M2
Mn-1
Mn
System
31
uses
B
32
Hierarchy
Organizes the modular
structure through levels of
abstraction
Each level defines an
abstract (virtual) machine
for the next level
Level can be defined
precisely
M
5
M
6
level 0
level 1
M2
M3
M4
M1 level 2
33
M M M
8 9
7
M
5
M2
M3
M1
B COMPRISES A
M1
M
6
M4
M2
M3
M M M
8 9
They are a hierarchy 7
M
5
M4
M
346
M
5
M2
M3
M1
M
6
M4
35
calls
B
36
Example: OO relations
Aggregation:
Defines objects or object classes as composed of simpler
components that constitute the parts of other objects.
This is a PART-OF relation (differs from IS-COMPOSED-OF)
Cardinality of the consituents
Package A
Triangle
1
Class 1
Class 3
Point
Triangle USES Point
Point IS-A-PART-OF Triangle
Not Triangle IS-COMPOSED-OF Point
Class 2
PackageA IS-COMPOSED-OF
Class1, Class2, Class 3
37
II. MODULARIZATION
TECHNIQUES
1. Module
2. Relations between modules
3. Specific techniques for design for change
38
39
Example: C pre-processor
//...source fragment common to all versions...
#ifdef hardware-1
//...source fragment for hardware 1 ...
#endif
#ifdef hardware-2
//...source fragment for hardware 2 ...
#endif
40
41
III. SOFTWARE
ARCHITECTURES
1. Definition
2. Common architectures
3. Domain specific architectures
42
Describes
Guides
the development of the design
43
Examples
STL for C++
JavaBeans and Swing for Java
44
2. Common architectures
Blackboard
Display model
for users
request
Model
store data
change
View
users
actions
Controller
views
selectio
n
to three tiered
User interface
(client)
Web browser
(client)
Requests
for service
(database)
Requests
for service
(pages)
Decode
service
request
(2nd tier)
Web server
(server)
Application
server
(database)
47
4. Component integration
Domain
Interfaces
CORBA
Facilities
CORBA Services
48
CONCLUSION
49
Key points
Divide and conquer strategy
We decompose to simplify the problem and to find
solutions in terms of the abstract machine we can
employ
When completed, we can compose
50