Software Architect
Software Architect
Software Architect
Software Architecture
and Design
Cesare Pautasso
http://www.pautasso.info
Spring Semester 2009
17.2.2009 Software Architecture and Design 9
©2009 Cesare Pautasso
Contents
• Architecture 101
• When do you need an Architect?
• Why do we need Software Architecture?
• Architecture within the Software Development
Process
• Course Overview
• Durability:
the building should last for a long time without falling down on
the people inside it
• Utility:
the building should be useful for the people living in it
• Beauty:
the building should look good and raise the spirits of its
inhabitants
Eberhardt Rechtin
1991
Spring Semester 2009
17.2.2009 Software Architecture and Design 20
©2009 Cesare Pautasso
When do you need
an architect?
It depends what you are trying to build…
60
40
20
0
Spring Semester 2009
17.2.2009 1990Software
1995Architecture2000
and Design 2005 2010 28
©2009 Cesare Pautasso
Software Architecture
As the size and complexity of a
software system increase, the
design decisions and the global
structure of a system become
more important than the
selection of specific algorithms
and data structures.
• Software Architecture
How to design large systems
• Component-based out of reusable components
Software Engineering
It is all in
my head!
Programme Manager
24.2.2009
IT Manager
Project Manager
Solutions Architect
Business Analyst
Development Manager
VB Developer
VC++/C++ Developer
Java Developer
Net Specialist
C# Specialist
Database Developer
Database Administrator
Network Manager
IT Trainer
Security Manager
Security Consultant
7
Marketing Analyst
Model the
problem Define
Requirements
Measure
Performance
Architect & Design Architect
IT Operations
Product Manager
Manager Manage
Manage Change
Program Modeler
Code
Deploy
Application Test
Support
Helpdesk
Developer
3. Implementation
4. Testing
5. Maintenance
Problem
Architecture Design
Definition
Data Models
Functional
Requirements
Code
Non-functional
Acceptance Tests
Requirements
Preliminary Architecture
requirements
analysis
Design of
architecture and
system core
Deployment
Operation
Alteration
Legacy
operation
Death
Spring Semester 2009
24.2.2009 Software Architecture and Design 19
©2009 Cesare Pautasso
Defining Software Architecture
From N. Taylor et al
system’s construction and evolution
Spring Semester 2009
24.2.2009 Software Architecture and Design 22
©2009 Cesare Pautasso
Design Decisions
• Design decisions • Principal Design Decisions:
cover all aspects of – the “important ones”
the system:
depending on the goals of the
– Structure stakeholders
– Behavior
• Decisions are made over time
– Interaction
– Deployment • Decisions are changed over
– Non-functional time
properties • Decisions depend on other
– Implementation decisions
Prescriptive Descriptive
Architecture Realization Architecture
Intent Recovery
System
Artifacts
From N. Taylor et al
Spring Semester 2009
24.2.2009 Software Architecture and Design 24
©2009 Cesare Pautasso
Green Field Development
Prescriptive Descriptive
Architecture Architecture
System
Artifacts
Prescriptive Descriptive
Architecture Architecture
System
Artifacts
P
D
P D
Ideal Case Realistic Case
Prescriptive Descriptive
Architecture Architecture
System
Intent Artifacts
From N. Taylor et al
Ad-hoc Changes
Spring Semester 2009
24.2.2009 Software Architecture and Design 28
©2009 Cesare Pautasso
From Drift to Erosion
• Over time, decisions are added to D
P
P D P
D
D
• Drift: new D decisions do not violate P
From N. Taylor et al
• Erosion: D decisions violate P decisions
Spring Semester 2009
24.2.2009 Software Architecture and Design 29
©2009 Cesare Pautasso
Solution vs. Product
From O. Zimmermann
Spring Semester 2009
24.2.2009 Software Architecture and Design 30
©2009 Cesare Pautasso
M-architecture, T-architecture
• Principal Design Decisions:
– the “important ones” depending on the goals of the stakeholders
From L. Hohmann
Spring Semester 2009
24.2.2009 Software Architecture and Design 31
©2009 Cesare Pautasso
The $10’000 Boolean Flag
SI 006 – 8:30-10:30
Customer Map:
Components
Requirements Function → Structure – Processing
Behavior – Data/State
Quality
Abstraction Connectors
Stakeholders Viewpoint – Communication
– Composition
– Collaboration
Can be composed
into larger systems
Processing
Provided Required
Interface Interface
State
Environment
Spring Semester 2009
17.3.2009 Software Architecture and Design 5
©2009 Cesare Pautasso
Black Box
• Components only accessible
from the “outside”
• Encapsulation
– Separate the content from the
rest of the system
• Abstraction
– Hide implementation details
behind the interface
• Modularity
– Reusable unit of assembly
Spring Semester 2009
17.3.2009 Software Architecture and Design 6
©2009 Cesare Pautasso
Transparent Boxes
• Black Box - Components only accessible through
its interface. Implementation is kept hidden.
• Glass box – Implementation can be inspected,
but not modified.
• Grey box – Implementation can be inspected,
but only limited modification is allowed
• White box – Implementation can be inspected
and modified completely
OS
http://sunnyday.mit.edu/accidents/Ariane5accidentreport.html
• In 1996, the maiden flight of the • “data conversion from 64-bit
Ariane 5 rocket ended in disaster floating point to 16-bit signed
when the launcher went out of control integer value. The floating point
40s after take off. number which was converted had
• The problem was due to a reused a value greater than what could
component from a previous version of be represented by a 16-bit signed
the launcher (the Inertial Reference integer. This resulted in an
System - SRI) that failed because exception being thrown… ”
assumptions made when that • This “lack of protection of this
component was developed did not conversion which caused the SRI
hold for Ariane 5. computer to stop”
• The functionality that failed in this
component was not required in Ariane
5.
Always validate your
“trusted components”
Spring Semester 2009
17.3.2009 Software Architecture and Design 12
©2009 Cesare Pautasso
Marketplaces
Platform-Independent
Portability
Centralized Platform-Dependent
Specific Language Agnostic
Thursday NO Exercise
Web Services
Services XML
J2EE
Components .NET
Eclipse
Objects C++
Java
Eiffel
C#
Spring Semester 2008
24.3.2009 Software Architecture and Design 4
©2008 Cesare Pautasso
Component vs. Objects
• Component • Object
– Encapsulate state and – Encapsulate state and
functionality functionality
– Coarse-grained – Fine-grained
– Reusable unit of composition – Identifiable unit of instantiation
– Well-defined (documented, – May not always provide a public
standardized) interface interface
contract with explicit – Hard to reuse by itself (lots of
dependencies dependencies to other objects)
– Architecture Element: – At run-time can “move” between
Implementation not components
important (Black Box) – Object-Oriented Programming
– High Quality Language Typing Construct
Enterprise
Java DCOM
.NET
Beans Objects
Assemblies
Web Legacy
CORBA
Services COBOL
Objects
Programs
Spring Semester 2008
24.3.2009 Software Architecture and Design 9
©2008 Cesare Pautasso
Interfaces
• Specify and document the
externally visible features
(or the public API) of the
component
• Operations
– Call functionality, modify state
• Information Hiding Principle:
• Properties always keep the
– Read visible state attributes implementation details
• Events secret (invisible from the
– “Call Backs” outside) and only access
• Dependencies them through the public
– What the component requires interface
WSDL
CORBA 1.0
DCOM
RPC IDL
MIDL
IDL
Java Interfaces
Spring Semester 2008
24.3.2009 Software Architecture and Design 12
©2008 Cesare Pautasso
Interface Design Principles
• Explicit Interfaces • Few Interfaces
– Components always – Every component
communicate through communicates with as few
interfaces others as possible
• Uniform Access • Clear Interfaces
– Facilities managed by – Do not publish useless
a component are accessible to functionality (unless it is
its clients in the same way used by other components)
whether implemented by • Small Interface
computation or by storage.
– If two components
Transfer signals
(data, control)
between ports
Linkage Stream
(Static/Dynamic)
Adapter
Arbitrator
Spring Semester 2008
24.3.2009 Software Architecture and Design 19
©2008 Cesare Pautasso
Adapter
Abstraction Quality:
some information Model •Ambiguity
is intentionally •Accuracy
left out
•Precision
“Real”
Interpretation
System solve ambiguities
add missing
decisions
Physical
“Real” View
System
Deployment
View
Spring Semester 2009
31.3.2008 Software Architecture and Design 10
©2009 Cesare Pautasso
Multiple Views
• There is too much information to model, we need
multiple views
Logical
View
Physical
“Real” View
System
Deployment
View
Spring Semester 2009
31.3.2008 Software Architecture and Design 11
©2009 Cesare Pautasso
Consistency Problem
• Views are not orthogonal and should not become
inconsistent
Logical
View
Physical
“Real” ! View
System
Deployment
View
Spring Semester 2009
31.3.2008 Software Architecture and Design 12
©2009 Cesare Pautasso
What is a View?
• No single modeling • A view is a set of design
approach can capture the decisions related by
entire complexity of a common concerns
software architecture (the viewpoint)
• Various parts of the
architecture (or views) may View
have to be modeled with a
different:
– Notation
– Level of detail
Viewpoint
– Target Audience
System
Spring Semester 2009
31.3.2008 Software Architecture and Design 13
©2009 Cesare Pautasso
4+1 View Model
Provided
Interface
Required
Interface
• Substitutability = ability to transparently replace the content
(implementation) of a component, provided its provided and
required interface contracts are not modified
Spring Semester 2009
7.4.2009 Software Architecture and Design 19
©2009 Cesare Pautasso
Deployment Diagrams
Node (Device, Execution Environment)
Component Artifact
Dependency
invoice order
ship
Spring Semester 2009
7.4.2009 Software Architecture and Design 24
©2009 Cesare Pautasso
Class Diagrams
Class 1 + ballDribble()
- TeamName: String
Attributes + ballPass()
- NumberofPlayer: Integer
exercise + rebound()
Class Association + shoot()
Operations
Generalization
Guard Forward
Team BasketballPlayer
Class Name
- TeamName: String - Name: String
- NumberofPlayer: Integer - Height: Float
- Weight: Float
+ ballDribble()
+ ballPass()
+ rebound()
+ shoot()
Spring Semester 2009
7.4.2009 Software Architecture and Design 27
©2009 Cesare Pautasso
Attributes and Operations
• Attributes • Visibility:
– Model properties of the class – Private
Syntax: Name: Type + Public
• Operations # Protected
~ Package
– Model methods of the class
Syntax: Name(param1:type, param2:type, ...) : Result
Team BasketballPlayer
Class - Name: String
- TeamName: String Attributes
- NumberofPlayer: Integer - Height: Float
- Weight: Float
Class + ballDribble()
Operations + ballPass()
+ rebound()
Spring Semester 2009 + shoot()
7.4.2009 Software Architecture and Design 28
©2009 Cesare Pautasso
Association and
Multiplicity
• Association
– Relationship between classes that specifies the existence of a
reference between their objects
• Multiplicity
– Number of instances of one class related to ONE instance of the other
class
Multiplicity Basketball Player
Association -Name: String
Team -Height: Float
1 employ * -Weight: Float
- TeamName: String
- NumberofPlayer: Integer + ballDribble()
1 * + ballPass()
exercise + rebound()
Association name + shoot()
Aggregation Composition
1 1 1 0 ..2
Address Body Panel Scrollbar
Transportation
Specialization Generalization
keyStroke or timeOut[slideshow]/
Initial mouseMovement popUpScreenShot()
State
Final
Screen State
State
Saving
Spring Semester 2009
7.4.2009 Software Architecture and Design 34
©2009 Cesare Pautasso
Transition
Syntax: event(arguments)[condition]/action
• Change state (may be triggered by an event)
• Occur only when guard condition is true
Screen
Saving
Plugged
Off On Mute
Unplugged
AND Decomposition
CD Radio Phone
Dependency <<include>>
<<include>>
Buy
Tickets
Buy Customer
Kiosk Subscription
Spring Semester 2009
7.4.2009 Software Architecture and Design 40
©2009 Cesare Pautasso
Use Case
• Unit of functionality (or feature) expressed as the interaction
among actors and the system
Box Office
Use Case
Survey Sales
Supervisor
Make Charges
Use Case Name
Credit Card <<include>>
Service <<include>>
Buy
Tickets
Buy Customer
Kiosk Subscription
Box Office
Survey Sales
Actor Supervisor
Make Charges
Credit Card <<include>>
Service <<include>>
Buy
Tickets
Buy Customer
Kiosk Subscription
Spring Semester 2009
7.4.2009 Software Architecture and Design 43
©2009 Cesare Pautasso
Identifying Actors
• Primary Actors:
– Who will use the main functionality of the system?
– Who will need support from the system to their daily tasks?
– Who or what has an interest in the results (the value) that the
system produces?
• Secondary Actors:
– Who will need to maintain, administrate, and keep the system
working?
– With which other systems does the system need to
interact/depend on?
Box Office
Survey Sales Inclusion
Use Cases
Supervisor
Make Charges
Credit Card <<include>>
<<include>> Dependency
Service
Buy
Tickets
Buy Customer
Kiosk Base Use Case Subscription
Method
Theft Intuition
System
Method Method
Theft Intuition
?
Classical System Unprecedented system
From R. Taylor
Spring Semester 2009
12.5.2009 Software Architecture and Design 6
©2009 Cesare Pautasso
Patterns
• Layered • Composition
– State-Logic-Display – Scatter/Gather
– Model-View-Controller – Master/Slave
• Service Oriented – Synchronous
Architecture – Asynchronous
– Interoperability • Testing
– Service Directory – Faux Implementation
• Notification – Wire Tap
– Event Monitor • Optimization
– Observer – Data Transfer Object
– Publish/Subscribe – Partial Population
– Messaging Bridge
State-Logic-Display
Model-View-Controller
State-Logic-Display
• Goal:
separate elements with different rate of change
• Solution:
cluster elements that change at the same rate
together
• Pattern:
apply the layered style to separate the user
interface (display/client), from the business logic
(server), from the persistent state (database) of the
system
Spring Semester 2009
12.5.2009 Software Architecture and Design 9
©2009 Cesare Pautasso
State-Logic-Display
Client Server Database
Business Business
Presentation
Logic Objects
Client is any user or The application logic The state layer deals with
program that wants to determines what the the organization (storage,
perform an operation with system actually does indexing, and retrieval)
the system (code, rules, constraints) of the data used by the
application logic
Spring Semester 2009
12.5.2009 Software Architecture and Design 10
©2009 Cesare Pautasso
Model-View-Controller
• Goal:
support different means of interaction and display of the
same content
• Solution:
separate content (model) from presentation (output) and
interaction (input)
• Pattern:
model objects are completely ignorant of the UI. When the
model changes, the views react. The controller's job is to
take the user's input and figure out what to do with it.
Controller and view should (mostly) not communicate
directly but through the model.
Spring Semester 2009
12.5.2009 Software Architecture and Design 11
©2009 Cesare Pautasso
Model-View-Controller
Controller View
(Interaction) Model (Display)
Input
Output
Interoperability
Service Directory
Interoperability
• Goal:
enable communication between different platforms
• Solution:
map to a standardized intermediate representation and
communication style
• Pattern:
components of different architectural styles running on
different platforms are integrated by wrapping them with
adapters. These adapters enable interoperability as they
implement a mapping to common means of interaction
• Goal:
facilitate location transparency
(avoid hard-coding service addresses in clients)
• Solution:
use a directory service to find service endpoints based
on abstract descriptions
• Pattern:
clients lookup services through a directory in order to
find out how and where to invoke them
Service
Description 1. Publish
2. Lookup
3. Invoke
• Goal:
inform clients about events happening at the service
• Constraint:
service does not support a publish/subscribe mechanism
• Solution:
poll and compare snapshots
• Pattern:
clients use an event monitor that periodically polls the
service, compares its state with the previous one and
notifies the clients about changes
1. poll(frequency)
Snapshot (A)
Snapshot (B)
2. compare(A,B)
3. notify
• Solution:
detect changes and generate events at the service
• Pattern:
clients register themselves with the service, which will inform
them whenever a change occurs
S.register(A) A
A.notify
B S.register(B)
A.notify B.notify
S.unregister(A) A
B.notify
Clients register a callback/notification endpoint with the service.
This is used by the service to notify all clients about state changes.
Clients should also unregister
Springthemselves
Semester 2009when no longer interested.
12.5.2009 Software Architecture and Design 25
©2009 Cesare Pautasso
Observer Hints
• Assuming that a service can implement it, this pattern improves on the
Event Monitor pattern:
– State changes are not downsampled by clients
– State changes are propagated as soon as they occur
– If no change occurs, useless polling by clients is spared
• Clients could share the same endpoint with several observed services.
Notifications should identify the service from which the event originates.
• To avoid unnecessary polling by the client, notification messages should
also include information about the new state and not just that a state
change has occurred.
• Warning: the set of registered clients becomes part of the state of the
service and may have to be made persistent to survive service failures.
• A client which stops listening without unregistering should not affect the
other registered clients
Spring Semester 2009
12.5.2009 Software Architecture and Design 26
©2009 Cesare Pautasso
Publish/Subscribe
• Goal:
decouple clients from services generating events
• Solution:
factor out event propagation and subscription management
into a separate service
• Pattern:
clients register with the event service by subscribing to certain
event types, which are published to the event service by a set
of one or more services.
Spring Semester 2009
12.5.2009 Software Architecture and Design 27
©2009 Cesare Pautasso
Publish/Subscribe Pattern
Pub/Sub
Client (C) Service (S)
(E)
E.subscribe(C) C
X E.publish(X)
X C.notify(S,X)
• Solution:
link multiple messaging systems to make messages exchanged on
one also available on the others
• Pattern:
introduce a bridge between the messaging systems, the bridge
forwards (and converts) all messages between the buses
M
E1.subscribe(M) M
E2.subscribe(M)
M E2.publish(M)
M B.notify(M)
M E1.publish(M)
M C.notify(M)
The bridge (B) replays all subscriptions made by clients one bus (E1)
onto the other (E2) so that it can inform the client (C) of one bus of
messages published on the other
Spring Semester 2009
12.5.2009 Software Architecture and Design 31
©2009 Cesare Pautasso
Messaging Bridge Hints
• Enable the integration of existing multiple messaging systems so that
applications do not have to use multiple messaging systems to
communicate
• Often it is not possible to use a single messaging system (or bus) to
integrate all applications:
– Incompatible messaging middleware (JMS vs. .NET MQ)
– External bus(es) vs. Internal bus
– One bus does not scale to handle all messages
• Although messaging systems may implement the same standard API, they
are rarely interoperable so they cannot be directly connected.
• Messaging bridges are available (or can be implemented) so that messages
can be exchanged between different buses. They act as a message
consumer and producer at the same time and may have to perform
message format translation.
Spring Semester 2009
12.5.2009 Software Architecture and Design 32
©2009 Cesare Pautasso
Composition
Scatter/Gather
Master/Slave
Synchronous
Asynchronous
Scatter/Gather
• Goal:
send the same message to multiple recipients which will
(or may) reply to it
• Solution:
combine the notification of the request with aggregation of
replies
• Pattern:
broadcast a message to all recipients, wait for all (or some)
answers and aggregate them into a single message.
Spring Semester 2009
12.5.2009 Software Architecture and Design 34
©2009 Cesare Pautasso
Scatter/Gather Pattern
Scatter/
Client A B C
Gather
Broadcast
Request
Aggregate
Results
• Solution:
split a large job into smaller independent partitions which can
be processed in parallel
• Pattern:
the master divides the work among a pool of slaves and
gathers the results once they arrive
Assign to
Slaves
Merge
Results
• Solution:
Build systems out of the composition of existing ones
• Pattern:
by including compositions as an explicit part of the architecture, it becomes
possible to reuse existing services in order to aggregate basic services into
value-added ones
Initiate
Progress
Notification
Completion
(Final result)
Composite services provide value-added services to clients by
aggregating a set of services and orchestrating them according
to a well-defined and explicit business process model
Spring Semester 2009
12.5.2009 Software Architecture and Design 41
©2009 Cesare Pautasso
Composition Hints
• Composition is recursive: a composite service is a service that can be
composed.
• Services involved in a composition do not necessarily have to know that they
are being orchestrated as part of another service and may be provided by
different organizations
• Services can be reused across different compositions and compositions can
be reused by binding them to different services
• Composite services may be implemented using a variety of tools and
techniques:
– Ordinary programming languages (Java, C#, …)
– Scripting languages (Python, PERL, …)
– Workflow modeling languages (JOpera, BPEL…)
• Compositions may be long-running processes and involve asynchronous
interactions (both on the client side, and with the services)
Spring Semester 2009
12.5.2009 Software Architecture and Design 42
©2009 Cesare Pautasso
Testing
Faux Implementation
Wire Tap
Faux Implementation
• Goal:
test a client separately from the services it depends on
• Solution:
bind the client to a local replacement
• Pattern:
the interfaces of the production services that are needed by the
client are implemented by mockup services. These are used to
test & debug the client that does not have to call the remote
service
Service
Interface
Testing Production
Client
Service Service
• Solution:
intercept messages in transit using a “wire tap”
• Design Pattern:
The wire tap replaces the intended destination of the messages,
forwards them to the original destination but also keeps a copy for
inspection
• Synonyms: Tee
Spring Semester 2009
12.5.2009 Software Architecture and Design 47
©2009 Cesare Pautasso
Wire Tap Pattern
Wire
Client Server Log
Tap
service.op1(a)
service.op2(b)
service.op(a,b,c,d)
service.op3(c)
service.op4(d)
key
key