Software design and architecture Content

advertisement
Software design and
architecture
by
Kristian Sandahl
Content
•
•
•
•
•
General design issues and principles
Architectural design
Architectural styles
Component-based design
Research at LiTH
1
Software engineering process
Support, Management, Tools, Methods, Techniques, Resources
Requirements
analysis
Acceptance
testing
System
design
Operation &
Maintenance
System
testing
Program
design
Unit & integration testing
Coding
The Ideal Design Process
• "The Design (Process) is the creative
process of transforming the problem
into a solution" [Pfleeger]
• "Design produces a workable solution to
a given problem" [Budgen]
• "Design is the description of a solution"
[Pfleeger]
2
The Ideal Design Process
• Starts from the requirements specification
(SRS) and documents
• Produces the Software Design document SD
• Groups into
– conceptual design/architecture: tells the WHAT of
the system
– technical design: Tells the HOW
• Groups into
– architectural design (coarse grain design)
– detailed design (module design, low level design)
• Is integrational
A Software Design Method
has three components:
• Representation part (notation part)
– set of notations in (informal) textual, (semi-formal)
diagrammatic, or mathematic (formal) form
• Process part
– Design strategy
• Set of heuristics
– rules of thumb, adaptation rules
• Result is the design model (design
specification, SD)
3
A Software Design Method:
Use-case modelling
has three components:
• Representation part (notation part)
– actor, use-case diagram, use-case text, classes
• Process part
– Start with use-cases, identify classes in the text, ...
• Set of heuristics
– Only model normal behaviour, keep diagrams
simple
• Result is the design model
Lazy or Eager Design
• In case of a difficult design decision
• defer it (lazy design)
– Iterative Software development meethods
such as Extreme Programming
• do it (eager design)
• anticipate further developments in the
design (anticipatory design)
4
The Divide and Conquer
Strategy
• Divide et impera (from Alexander the
Great)
• Scheme
– divide (divide): problems into subproblems
– conquer: solve subproblems (hopefully
easier)
– compose (merge): compose the complete
solution from the subsolutions
Important Concepts
• A small number of items
– never use more than 5 items
• KISS (keep it simple stupid)
– remove all superfluous things, make it fit on 1
page
• Separation of concerns
– different concepts should be separated out
• Use hierarchies!
– trees, trees, trees
5
Coupling and cohesion
class
method
method
method
class
method
method
method
many
few
class
method
method
method
class
method
method
method
Parnas’ information hiding
principle
• Hide design decisions within in a
module
• Better software understanding
• Better module replacability
• Concurrent design
6
Information hiding example
Requirement
Responsible
1 Kristian
2 Jens
3 Calle
Priority
Description
2 book ticket
1 pay ticket
1 print ticket
1. Sort Requirements according to Priority
2. Sort Rows according to Column3 numerically
3. quicSort(sheet, rows, 3, num)
4. while not(sorted) .....
Software architecture
• The overall organisation of the system
as a collection of interacting
components
• Roles of architecture:
– Understanding, at best exposes high-level
constraints of the system
– Reuse, of components and high-level
patterns, there are frameworks to buy
7
Software architecture
• Roles of architecture (cont’d):
– Construction, a partial blueprint including
major interfaces of the system
– Evolution, ”the load-bearing walls” can be
depicted, cost of change estimated
– Analysis, consistency checing and
conformance analysis of the system
– Management, a key milestone, leads to
implementation strategies
Layering
Each layer provides service
to the adjacent outside layer,
and acts as a client to the
adjacent inside layer.
The design prescribes rules
and protocols for communication
between layers.
Advantages:
•Implements information hiding
•Modifications can be performed
locally on one layer
Disadvantages:
•Supports incremental approach
•Not always obvious how to
define layers
•Supports incremental testing
•Potential performance problems
8
Pipes and filters
Processes streams of data
in independent components
called filters.
Examle: Unix shell commands
a > b > c ...
Advantages:
•Good system understanding
•Reuse of filters supported
Disadvantages:
•Evolution is supported
•limited to batch processing
•Supports simulation
•glue filters are necessary
•Allows more complex architectures
concurrency, matrices
•functions are duplicated
•Facilitates use of formal specification
Process control
A software realisation of
an independent control system.
The controller maintains a set
point for a variable by changing
input to a process.
Good separation of concerns.
Example: Air Condition
Needs caution when:
•selecting variables
•measuring variables
•selecting algorithm
•handling exceptions
9
Object-oriented design
• Generalisation of hierarchical composition
• Decomposes the problem in independent
units
• Relations between objects are well depicted
• Encapsulation support top-down design and
replacability
• Polymorphism reduced function complexity
• Correspondence with object-oriented
ananlysis and classes in Java, C++, C#, ...
Blackboard
A development of database repository
architecture.
Knowledge sources post data
in a common repository.
The respository processes shared
data and can invokate processes
in knowledge sources
Example: Military intelligence
system
Advantages:
•Supports incremental development
•Easy to change knowledge sources
Difficulty:
•Create a suitable and general
knowledge representation.
10
Interpreters
Transforms pseudocode
into a instructions for a
simulator.
Example: Simulation of
mathematical models.
Advantages:
•Allows users to express
themselves in more natural
terms.
•Supports creation of domainspecific languages
Problem:
•Performance
Motivation for Component
Based Development
• Divide-and-conquer (Alexander the Great)
• Well known in other disciplines
– mechanical engineering DIN 2221
– electrical engineering
– architecture
• Outsourcing to component producers
(components off the shelf, COTS)
• Reuse of partial solutions: instead of new
solution
• Easy configurability of the systems
– variants, versions, product families
11
Motivation: Reuse
Goal: cost
reduction
• size of class libraries
– JDK 1.1: ca 1,650 classes
– JDK 1.2: ca 4,000 classes
Reuse rates
Time [m.m.]
# Developers
Costs per l.o.c. [DM]
Lines per m.m.
Savings [DM]
Savings
0%
81,5
8
70
165
-
25%
45
6
37
263
~ 400.000
~ 45%
50%
32
5
28
370
~ 560.000
~ 60%
From: C. Jones, The Impact of Reusable Modules and Functions, in
Programming Productivity, Mc Graw Hill, 1986
Other Goals
• Product quality
–
–
–
–
–
quality improvement
effectivity by concentration to optimizations
reliability
prolongation life time
flexibilization
• Improvements in the software process
– productivity
– almost prototype construction
– simulation of architectures
• Documentation
– clear system structures
12
CORBA
• Language independent, distribution
transparent
• interface definition language IDL
• source code or binary
Client
Java
Client
C
IDL
IDLStub
Stub
Server
C++
http://www
.corba.org
IDL
IDL
skeleton
skeleton
IDL
IDLStub
Stub
Object
Objectadapter
adapter
Object Request Broker (ORB), Trader, Services
Integrational Software Engineering
R1
R3
R2
R4
Final
system
C1
C2
Op2
Op3
C3
Op1
Op5
A1
13
Modelica – the Next Generation
Computational Modeling Language
• Declarative language
– Equations and mathematical functions allow acausal modeling, high
level specification, increased correctness
• Multi-domain modeling
– Combine electrical, mechanical, thermodynamic, hydraulic,
biological, control, event, real-time, etc...
• Everything is a class
– Strongly typed object-oriented language with a general class
concept, Java & Matlab like syntax
• Visual component programming
– Hierarchical system architecture capabilities
• Efficient, non-proprietary
– Efficiency comparable to C; advanced equation compilation, e.g.
300 000 equations, ~150 000 lines on standard PC
Modelica Visual Programming:
Decomposition and Abstraction of an Automatic
Gearbox
d
e
m
u
ptli
el
x
bearing4
bearing2
bearing1
2
1.
0
=
2
1
C
2
1.
0
=
6
C
C
8
=
0.
1
2
shaftS=2e-3
shaftS1=2e-3
S
C4=0.12
S
C5=0.12
C11=0.12
planetary1=110/50
planetary2=110/50
planetary3=120/44
14
Hierarchical Composition of a Modelica Model of an
Industrial Robot
k2
i
qddRef
qdRef
qRef
1
1
S
S
k1
cut joint
r3Control
r3Motor
axis6
tn
r3Drive1
1
i
qd
axis5
l
qdRef
Kd
S
rel
0.03
Jmotor=J
qRef
pSum
-
Kv
0.3
sum
w Sum
+1
+1
-
rate2
rate3
b(s)
340.8
a(s)
S
joint=0
spring=c
S
iRef
axis4
gear=i
0
v
R
=
ci
rf
axis3
rate1
tacho2
b(s)
b(s)
a(s)
a(s)
tacho1
PT1
g5
q
qd
axis2
0
5
=
2
p
R
C=0.004*D/w m
Rd1=100
Rd2=100
-
Ri=10
Rp1=200
-
R
a
=
2
5
0
L
a
=
2(
5
0
/
2(
*
D
*
w
m
))
+
+
Srel = n*n' + (identity(3) - n*n')*cos(q)
- skew(n)*sin(q);
+
diff
pow er
OpI
wrela = n*qd;
zrela = n*qdd;
Rd4=100
V
s
emf
Sb = Sa*Srel';
0
r0b = r0a;
0
g3
1
=
3
vb = Srel*va;
d
g1
R
wb = Srel*(wa + wrela);
ab = Srel*aa;
h
a
hall1
w
zb = Srel*(za + zrela + cross(wa,
wrela));
2l
fa = Srel'*fb;
ta = Srel'*tb;
g4
g2
qd
axis1
y
x
inertial
r
q
15
Download