Chapter3 DevelopementSoftwareArchitecture
Chapter3 DevelopementSoftwareArchitecture
DEVELOPMENT OF SOFTWARE
ARCHITECTURE
Design techniques
Design patterns
Architectural patterns
3
DEVELOPMENT PROCESS OF
ARCHITECTURES
4
ITERATIVE DEVELOPMENT OF
ARCHITECTURE
5
ITERATIVE DEVELOPMENT OF
ARCHITECTURE
6
PROCESS OVERVIEW
7
FIRST STEP – COLLECT INFORMATION
8
FIRST STEP – COLLECT INFORMATION
Acquire required domain knowledge and
technical background for the project.
Identify existing systems in the organization
and verify the reusability.
Identify systems offered by third parties, which
perform the similar task or at least a part of
it, such as the system to be developed.
Study appropriate technical literature needed
for solution approaches and process models.
9
SYSTEM CONCEPTS
What is the core task of the system?
The main task and responsibility of a system are
described in a few words with reference to the most
important concepts and aspects of the business
domain.
11
INFLUENCING FACTORS AND CONSTRAINTS
Organizational / political
Technical
12
ORGANIZATIONAL FACTORS
13
TECHNICAL FACTORS
14
STEP 3 – INDENTIFY RISKS
15
TYPICAL RISKS
Reconsider decision 17
DESIGN PRINCIPLES &
HEURISTICS
18
STEP 4 – DESIGN STRUCTURE AND
TECHNICAL CONCEPTS
19
PRINCIPLES OF DECOMPOSITION
Design in iterations.
Consider alternatives to the obvious approaches.
Independent elements.
20
DECOMPOSITION APPROACHES
22
BOTTOM-UP
Advantages Disadvantages
23
DIVIDE AND IMPERA
The task on hand will be decomposed into
smaller subtasks until the complexity of these
tasks is manageable.
Simplicity effects:
26
USAGE OF INTERFACES
The most important aspects of the architecture
are interfaces and relationships between the
components
27
DESIGN TECHNIQUES
(HANDLING DEPENDENCIES)
28
HANDLING DEPENDENCIES :
PROBLEMATIC
Too much dependencies = degenerated
design
Others OO technics.
30
LOOSE COUPLING
We should construct dependencies in design in such a way
that the future changes produce no new dependencies.
Gernot Starke
Tight coupling
(Subclassing) Abstract ("Looser") coupling
extends
composition
Loose coupling
aggregation 32
HIGH COHESION
The higher the cohesion, the more interrelated is the
responsibility of a class in the application.
A cohesive class:
Solves one problem.
Has a specific amount of strongly related functionalities.
33
HIGH COHESION
High cohesion
Low cohesion
34
SINGLE-RESPONSIBILITY PRINCIPLE
37
LISKOV SUBSTITUTION PRINCIPLE
Barbara Liskov
38
INTERFACES SEGREGATION
Several specific interfaces are better than a
large universal interface.
Gernot Starke
44
ADVANTAGES OF USE OF PATTERNS
45
COMMON PATTERNS CATALOGS
Architectural Patterns
46
DESIGN PATTERN
47
WHAT DESIGN PATTERNS DO
Design patterns address two general concerns:
Motivation:
A system should be independent of how its products
are created, composed, and represented.
A system should be configured with one of multiple
families of products.
Providing a class library of products by revealing just
their interfaces, not their implementations. 51
ABSTRACT FACTORY PATTERN:
STRUCTURE
52
ABSTRACT FACTORY PATTERN:
EXAMPLE SOLUTION Abstract
Products
Abstract
Factory
Concrete Concrete
factories products
53
ABSTRACT FACTORY PATTERN:
SYNTHESIS
Problems:
Create families of related or dependent objects
without specifying their concrete classes.
Hide the concrete product classes from the client.
Advantage:
Provide different kinds of objects through a single
interface.
Clients are independent of implementation.
54
PROTOTYPE
55 Creational GOF’s pattern
PROTOTYPE PATTERN:
PRESENTATION
Intent:
Specify the kinds of objects to create using a
prototypical instance, and create new objects by
copying this prototype.
Motivation:
A system should be independent of how its products
are created, composed, and represented.
The classes to instantiate are specified at run-time,
for example, by dynamic loading.
56
PROTOTYPE PATTERN:
STRUCTURE
57
PROTOTYPE PATTERN:
EXAMPLE SOLUTION Prototype
Client
Concrete
prototypes
58
PROTOTYPE PATTERN:
SYNTHESIS
Problems:
Hide the concrete product classes from the client.
Instances of a class can have one of only a few
different combinations of state.
Avoid building a class hierarchy of factories that
parallels the class hierarchy of products.
Specifying instantiated classes at runtime.
Advantage:
Provide new objects by copying an example rather
than producing uninitialized new instances of a class.
59
FACADE
60 Structural GOF’s pattern
FACADE PATTERN:
PRESENTATION
Intent:
Provide a unified interface to a set of interfaces in a
subsystem. Facade defines a higher-level interface
that makes subsystem easier to use.
Motivation:
61
FACADE PATTERN:
STRUCTURE
62
FACADE PATTERN:
EXAMPLE PROBLEM
Client is coupled to many classes in the reservation
subsystem.
63
FACADE PATTERN:
EXAMPLE SOLUTION
64
FACADE PATTERN:
SYNTHESIS
Problem: When a client directly links to many classes:
It is vulnerable to changes in any of those classes.
It must know each one’s interface.
It must devise an order for calling operations and delegating
parameters to them.
In a distributed environment, many fine-grained client calls can also
increase network overhead.
Advantages:
The client is decoupled from the subsystem components.
The client does not have to know the underlying process.
There are fewer network trips in a distributed environment.
Clients can still communicate directly with the subsystems.
Disadvantage:
A layer of indirection obscures the underlying process. 65
ADAPTER
66 Structural GOF’s pattern
ADAPTER PATTERN:
Intent:
Convert the interface of a class into another interface
clients expect. Adapter lets classes work together that
couldn't otherwise because of incompatible interfaces.
Motivation:
Problem
Solution
67
ADAPTER PATTERN :
STRUCTURE
68
ADAPTER PATTERN:
EXAMPLE Adaptee
Target
Adapter
Client
69
ADAPTER PATTERN:
SYNTHESIS
Problems:
When using an existing class, and its interface does not
match the one you need.
When creating a reusable class that cooperates with
unrelated or unforeseen classes, that is, classes that
don't necessarily have compatible interfaces.
Advantages:
Adapter as a bridge between two incompatible
interfaces.
Joining functionalities of different interfaces through a
single class. 70
STRATEGY
71 Behavioral GOF’s pattern
STRATEGY PATTERN:
PRESENTATION
Intent:
Define a family of algorithms, encapsulate each one,
and make them interchangeable. Strategy lets the
algorithm vary independently from clients that use it.
Motivation:
We need different variants of an algorithm.
Replacing or adding algorithms requires code modification.
A class defines many behaviors.
Multiple conditional statements in its operations.
72
STRATEGY PATTERN:
STRUCTURE
73
STRATEGY PATTERN:
EXAMPLE PROBLEM
74
STRATEGY PATTERN:
EXAMPLE SOLUTION
75
STRATEGY PATTERN:
SYNTHESIS
Problem:
Classes often need to choose from multiple algorithms.
The details of these algorithms should be hidden from client
classes.
Separating choices by conditional logic is hard to maintain.
Advantages:
Adding new strategies doesn’t affect the existing code.
Branch logic that can grow over time can be avoided.
Each algorithm is expressed separately.
Change to one algorithm is isolated from other algorithms.
Disadvantage:
76
Clients must know which strategies are available.
OBSERVER
77 Behavioral GOF’s pattern
OBSERVER PATTERN:
PRESENTATION
Intent :
Define a one-to-many dependency between objects so
that when one object changes state, all its
dependents are notified and updated automatically.
Motivation:
78
OBSERVER PATTERN:
STRUCTURE
79
OBSERVER PATTERN:
EXAMPLE PROBLEM
The faulted() method delegates a message to services
that are coupled to the FaultMessageGenerator class.
Other fault handlers may be needed.
80
OBSERVER PATTERN:
EXAMPLE SOLUTION
81
OBSERVER PATTERN:
SYNTHESIS
Problem:
Several classes want to monitor changes in another class:
Synchronous polling for asynchronous state changes may waste
resources.
Multiple observers polling an observable object may also require
synchronization controls.
Observers must know how to get to an observable object.
Advantages:
Subjects and observers can be reused independently.
Coupling is based on abstract type, not concrete type. 82
Examples:
MVC pattern.
Layers pattern.
Blackboard architecture pattern. 84
Pipe and filter pattern.
THE MVC PATTERN:
PRESENTATION
Motivation:
85
THE MVC PATTERN:
PRESENTATION
Intent:
Separates the concerns.
View: Displays a GUI with the Model component data. It may also
pass GUI-driven events to the Controller components.
87
THE MVC PATTERN:
STRUCTURE
Model
• Encapsulates application state
• Responds to state queries
• Exposes application functionality
• Notifies views of changes
State State
Query Change
Change
Notification
Method Invocations 88
Events
THE MVC MODEL:
KNOWN USES
Interactive systems.
89
THE MVC PATTERN:
HOW DOES IT WORK?
90
THE MVC PATTERN:
HOW DOES IT WORK?
91
THE MVC PATTERN:
HOW DOES IT WORK?
92
APPLYING THE MVC PATTERN:
EXAMPLE PROBLEM
93
APPLYING THE MVC PATTERN: EXAMPLE
SOLUTION
94
APPLYING THE MVC PATTERN:
BENEFITS & LIABILITIES
Benefits:
Multiple views offer simple or detailed perspectives.
It is easier to modify the Model, View, and Controller
components separately.
Some developers specialize on the UI, whereas others
specialize on the model.
Liabilities:
A very simple implementation of subsystems may
greatly increase the communication overhead (large
number of listeners).
95
THE LAYERS PATTERN:
PRESENTATION
Motivation:
When system has different levels of abstraction.
When requests go down and notification goes back
up.
When needing to change or add layers over time.
Intent :
Helps establish logical tiers and technology layers.
Defines and enforces abstraction boundaries.
96
THE LAYERS PATTERN:
PRESENTATION
Structures the system on the base of services offered
by underlying layers.
Abstraction increases with the number of underlying
layers.
Service usage only takes place directly between
successive layers.
Service usage is directed from upper to lower layer
(communication is in both ways).
A layer « j » can use service of j-1, j-2, etc.
The reverse direction or access through an
intermediate layer should be allowed only in
97
exceptional cases.
THE LAYERS PATTERN:
STRUCTURE
98
THE LAYERS PATTERN:
KNOWN USES
Virtual Machines.
APIs.
Information systems.
99
LAYERS AND COMPONENTS
100
THE LAYERS PATTERN:
EXAMPLE
101
THE LAYERS PATTERN:
BENEFITS
Reuse of layers.
Exchangeabilities:
Replacement of old implementation with Adapter Pattern.
Dynamic exchange with Bridge Pattern. 102
THE LAYERS PATTERN:
LIABILITIES
Cascades of changing behavior.
Lower efficiency.