You are on page 1of 73

Software Architecture

CS130
Lecture 5

Prof. Majumdar CS 130 Lecture 5

Administrivia
Requirement documents were due today
One document per team
Dont worry if you think it is not perfect yet it is
likely to change over the quarter

Design document due next Monday (see


website)
Design presentation next Monday
Project 3 will ask for design reviews by other
teams
Prof. Majumdar CS 130 Lecture 5

Administrivia: NDAs
When you work on a project, you can be privy
to a lot of confidential information from a
client
Non-disclosure agreement
Business issues?
Ethical issues?
What happens when you switch jobs?

Prof. Majumdar CS 130 Lecture 5

Software architecture
The design process for identifying the subsystems making up a system and the
framework for sub-system control and
communication is architectural design.
The output of this design process is a
description of the software architecture.

Prof. Majumdar CS 130 Lecture 5

Architectural design
An early stage of the system design process.
Represents the link between specification and
design processes.
Often carried out in parallel with some
specification activities.
It involves identifying major system
components and their communications.

Prof. Majumdar CS 130 Lecture 5

Advantages
Stakeholder communication

Architecture may be used as a focus of discussion by


system stakeholders

System analysis

Means that analysis of whether the system can meet


its non-functional requirements is possible

Large-scale reuse

The architecture may be reusable across a range of


systems
Prof. Majumdar CS 130 Lecture 5

Architectural design decisions


Is there a generic application architecture that can
be used?
How will the system be distributed?
What architectural styles are appropriate?
What approach will be used to structure the system?
How will the system be decomposed into modules?
How will the architectural design be evaluated?
How should the architecture be documented?

Prof. Majumdar CS 130 Lecture 5

Architecture reuse
Systems in the same domain often have similar
architectures that reflect domain concepts
Application product lines are built around a
core architecture with variants that satisfy
particular customer requirements

Prof. Majumdar CS 130 Lecture 5

Architectural styles
In order to create more complex software it is necessary
to compose programming patterns
For this purpose, it has been useful to induct a set of
patterns known as architectural styles
Examples:

Pipe and filter


Event based/event driven
Layered
Repository
Object-oriented
Process control
Model-view-controller
Prof. Majumdar CS 130 Lecture 5

Software Architectural Styles


Constituent parts:

Components
Connectors
Interfaces
Configurations

Prof. Majumdar CS 130 Lecture 5

Example

Prof. Majumdar CS 130 Lecture 5

What are components?


Components are the loci of computation
Components do the work in the architecture
May be coarse-grained (an editor)
or fine grained (a clock emitting ticks)

Prof. Majumdar CS 130 Lecture 5

What are connectors?


Connectors are the loci of communication
Connectors facilitate communication among
components

May be fairly simple (Broadcast Bus)


or complicated (Middleware-enabled)
May be implicit (events)
or explicit (procedure calls, ORBs, explicit
communications bus)

Prof. Majumdar CS 130 Lecture 5

What are interfaces?


Interfaces are the connection points on
components and connectors
They define where data may flow in and out of the
components/connectors
May be loosely specified (events go in, events go out)
or highly specified

Prof. Majumdar CS 130 Lecture 5

What are configurations?


Configurations are arrangements of
components and connectors to form an
architecture

Prof. Majumdar CS 130 Lecture 5

Common architectural styles

Pipe-and-filter
Repositories
Event based systems (implicit invocation)
Model-View-Controller
Layered systems
Object-oriented architectures
Process controls

Prof. Majumdar CS 130 Lecture 5

Pipe-and-filter
Source: Adapted from Shaw & Garlan 1996, p21-2.

filter

pipe

filter

pipe
filter

pipe
filter
pipe
pipe
pipe

pipe

filter
filter

pipe
pipe

Data flow styles: Filters transform input into output

components: filters -computational i.e. retain minimal state


connectors: data streams
control: data flow between components
Topologies: arbitrary, acyclic, pipeline (linear)
Prof. Majumdar CS 130 Lecture 5

Example: Traditional Compilers

Prof. Majumdar CS 130 Lecture 5

Pipe-and-filter
Examples:

UNIX shell commands


Compilers:

Lexical Analysis -> parsing -> semantic analysis -> code


generation

Signal Processing

Interesting properties:

filters are independent entities


filters dont need to know anything about what they
are connected to
Prof. Majumdar CS 130 Lecture 5

Example: Click
Network routers are complicated pieces of
code
Eddie Kohlers idea: Write routers as modular
components connected by pipe-and-filter

Prof. Majumdar CS 130 Lecture 5

Pipe-and-filter
Advantages

Overall behavior can be understood as a simple


composition of the behaviors of individual filters
Support reuse
Existing filers can be hooked up to form a system

Easy maintenance and enhancement


New filters can replace old ones

They support parallel execution


Support specialized analysis, such as throughput
and deadlock analysis

Prof. Majumdar CS 130 Lecture 5

Pipe-and-filter
Disadvantages

Not good for handling interactive applications


Complete transformation of input data to output data

Difficult to maintain correspondences between two


separate but related streams
Extra overhead to parse and unparse data

Prof. Majumdar CS 130 Lecture 5

Think About
How to schedule a pipe-and-filter
architecture on a sequential or multi-core
machine?

Prof. Majumdar CS 130 Lecture 5

Repositories
Source: Adapted from Shaw & Garlan 1996, p26-7.

agent

agent
agent
agent

blackboard
(shared
data)

agent
agent

Repositories: blackboard or database: Centralized data, usually


structured
components: central data store, many computational objects
connectors: computational objects interact with central store
directly or via method invocation
control: may be external, predetermined or internal
topology: star
Prof. Majumdar CS 130 Lecture 5

Example: Compiler Optimization

Prof. Majumdar CS 130 Lecture 5

Repositories

Examples

databases
modern compilers
programming environments

can choose where the locus of control is (agents,


blackboard, both)
reduce the need to duplicate complex data

blackboard becomes a bottleneck

Interesting properties

Disadvantages

Prof. Majumdar CS 130 Lecture 5

Event based (implicit invocation)


Source: Adapted from Shaw & Garlan 1996, p23-4.

agent

announce
event
broadcast
broadcast
medium
medium

agent
listen for
event

agent listen for event

announce agent
event
event based: implicit invocation: Independent reactive objects
(or processes)
components: objects that register interest in events and objects
that signal events
connectors: automatic method invocation
control: decentralized, de-coupling of sender and receiver
topologies: arbitrary
Prof. Majumdar CS 130 Lecture 5

Event based (implicit invocation)


Examples

debugging systems (listen for particular breakpoints)


database management systems (for data integrity checking)
graphical user interfaces

Interesting properties

announcers of events dont need to know who will handle the


event
Supports re-use
Supports evolution of systems (add new agents easily)

Disadvantages

Components have no control over ordering of computations


Nor do they know when they are finished
Correctness reasoning is difficult
Prof. Majumdar CS 130 Lecture 5

More Examples
Web servers, file servers
Embedded Systems
Sensor networks

Business processes (Long running transactions)

Prof. Majumdar CS 130 Lecture 5

Model-View-Controller

Prof. Majumdar CS 130 Lecture 5

Example of Model-View-Controller

Prof. Majumdar CS 130 Lecture 5

Layered Systems
Source: Adapted from Shaw & Garlan 1996, p25.

application layer

users

utilities
kernel

Layered system: Independent processes


Components: processes
Connectors: protocols that determine how layers
interact
Topologies: layered
Prof. Majumdar CS 130 Lecture 5

Example: ISO Network Protocol

Prof. Majumdar CS 130 Lecture 5

Layered Systems
Examples

Operating Systems
communication protocols

Interesting properties

Support increasing levels of abstraction during


design
Support enhancement (add functionality)
Change in one layer affects at most two layers

Reuse

can define standard layer interfaces


interchange implementations of same interface
Prof. Majumdar CS 130 Lecture 5

Layered Systems
Disadvantages

May not be able to identify (clean) layers


For performance reasons one layer may want to
communicate with a non-adjacent layer

Especially true in real-time performance critical systems


(cross layer design may be more efficient)

Prof. Majumdar CS 130 Lecture 5

Object Oriented Architectures


method
invocation

object

object

Source: Adapted from Shaw & Garlan 1996, p22-3.

object

method
invocation

object

object

method
invocation

method
invocation

Objected-oriented styles: data abstraction: Localized state


maintenance (encapsulation)

components: managers
connectors: method invocation
control: decentralized
topologies: arbitrary
Prof. Majumdar CS 130 Lecture 5

Object Oriented Architectures


Examples:

abstract data types


object broker systems (e.g. CORBA)

Interesting properties

data hiding (internal data representations are not


visible to clients)
Can change implementation without affecting clients

can decompose problems into sets of interacting agents

Disadvantage

objects must know the identity of objects they wish to


interact with
Prof. Majumdar CS 130 Lecture 5

Process Control
Source: Adapted from Shaw & Garlan 1996, p27-31.

input variables
control
parameters

controller

manipulated
variables

rs
o
ns
e
s

process

actuators

controlled
variables

Process control:
components: autonomous processes that continually read input
signals and write output signals
connectors: message passing network
control: decentralized, de-coupling of controller and process
topologies: arbitrary

Prof. Majumdar CS 130 Lecture 5

Process Control
Examples

aircraft/spacecraft flight control systems


controllers for industrial production lines, power stations,
etc.
chemical engineering

Interesting properties

separates control policy from the controlled process


handles real-time, reactive computations

Disadvantages

Difficult to specify the timing characteristics and response


to disturbances

Prof. Majumdar CS 130 Lecture 5

Summary
Architecture is what enables us to scale up
our software to handle larger applications
You must gain the ability to match the right
architecture to the right application

Prof. Majumdar CS 130 Lecture 5

Think About
How can architectures help reason about nonfunctional requirements?

Safety?
Security?
Dependability?
Performance?
Availability?
Maintainability?

Prof. Majumdar CS 130 Lecture 5

Examples
Performance

Localize critical operations and minimize communications. Use large


rather than fine-grain components.

Security

Use a layered architecture with critical assets in the inner layers

Safety

Localise safety-critical features in a small number of sub-systems

Availability

Include redundant components and mechanisms for fault tolerance

Maintainability

Use fine-grain, replaceable components.

Prof. Majumdar CS 130 Lecture 5

Conflicts
Using large-grain components improves
performance but reduces maintainability
Introducing redundant data improves availability
but makes security/consistency more difficult
Localizing safety-related features usually means
more communication so degraded performance
Prof. Majumdar CS 130 Lecture 5

Distributed Architectures

Prof. Majumdar CS 130 Lecture 5

Distributed systems architectures


Client-server architectures
Distributed services which are called on by clients.
Servers that provide services are treated
differently from clients that use services.

Distributed object architectures


No distinction between clients and servers. Any
object on the system may provide and use services
from other objects.
Prof. Majumdar CS 130 Lecture 5

Middleware
Software that manages and supports the different
components of a distributed system. In essence, it
sits in the middle of the system.
Middleware is usually off-the-shelf rather than
specially written software.
Examples
Transaction processing monitors;
Data converters;
Communication controllers.

Prof. Majumdar CS 130 Lecture 5

Multiprocessor architectures
Simplest distributed system model.
System composed of multiple processes which
may (but need not) execute on different
processors.
Architectural model of many large real-time
systems.
Distribution of process to processor may be
pre-ordered or may be under the control of a
dispatcher.
Prof. Majumdar CS 130 Lecture 5

A multiprocessor traffic control system

Sensor
processor
Sensor
control
process

Traffi c fl ow
processor

Traffi c light control


processor

Display
process

Light
control
process

Traffi c lights
Traffi c fl ow sensors and
cameras

Operator consoles

Prof. Majumdar CS 130 Lecture 5

Client-server architectures
Application modelled as a set of
services provided by servers and
set of clients that use these services
Network for communication

Clients know of servers but servers need not


know of clients
Clients and servers are logical processes
Prof. Majumdar CS 130 Lecture 5

Client-server characteristics
Advantages
Distribution of data is straightforward
Makes effective use of networked systems
Easy to add new servers or upgrade existing servers

Disadvantages
No shared data model so sub-systems use different data
organisation. Data interchange may be inefficient
Redundant management in each server;
No central register of names and services - it may be hard to
find out what servers and services are available
Prof. Majumdar CS 130 Lecture 5

A client-server system

c3

c2

c4

c12
c11
s4

s1

c1

Server process

c10
c5
s2

c6

c7

Client process
s3

c9

c8

Prof. Majumdar CS 130 Lecture 5

Computers in a C/S network

c1
CC1

c2
CC2

CC3

c3, c4

Network

s1, s2

s3, s4

SC2

Server
computer

SC1

c5, c6, c7

c8, c9
CC4

CC5

c10, c11, c12


CC6

Prof. Majumdar CS 130 Lecture 5

Client
computer

Thin and fat clients


Thin-client model
All of the application processing and
management is carried out on the server

data

Client is responsible for running the presentation


software

Fat-client model

Server is only responsible for data management


Software on the client implements the application
logic and the interactions with the system user

Prof. Majumdar CS 130 Lecture 5

Thin and fat clients

Presentation
Thin-client
model

Data management
Application processing

Client

Presentation
Application processing
Fat-client
model

Server

Client

Server
Data management

Prof. Majumdar CS 130 Lecture 5

Thin client model


Used when legacy systems are migrated to
client server architectures.
Legacy system acts as a server in its own right with
a graphical interface implemented on a client.

Disadvantage:
places a heavy processing load on both the server
and the network
latency
Prof. Majumdar CS 130 Lecture 5

Fat client model


More processing is delegated to the client as the
application processing is locally executed
Most suitable for new C/S systems where the
capabilities of the client system are known in
advance
More complex than a thin client model especially
for management. New versions of the application
have to be installed on all clients.
Prof. Majumdar CS 130 Lecture 5

Layered application architecture


Presentation layer
Concerned with presenting the results of a computation to
system users and with collecting user inputs

Application processing layer


Concerned with providing application specific functionality
e.g., in a banking system, banking functions such as open
account, close account, etc.

Data management layer


Concerned with managing the system databases

Prof. Majumdar CS 130 Lecture 5

Application layers

Presentation layer

Application processing
layer

Data management
layer
Prof. Majumdar CS 130 Lecture 5

Three-tier architectures
Allows for better performance than a thinclient approach
Simpler to manage than a fat-client approach
Recall: MVC
A more scalable architecture - as demands
increase, extra servers can be added.
Prof. Majumdar CS 130 Lecture 5

A 3-tier C/S architecture

Presentation
Client

Server

Server

Application
processing

Data
management

Prof. Majumdar CS 130 Lecture 5

An internet banking system

Client

Client

HTTP interaction

Web server
Account service
provision

SQL query

Client

Client

Prof. Majumdar CS 130 Lecture 5

Database server
SQL

Customer
account
database

Distributed object architectures


There is no distinction in a distributed object
architectures between clients and servers.
Each distributable entity is an object that provides
services to other objects and receives services from
other objects.
Object communication is through a middleware system
called an object request broker.
However, distributed object architectures are more
complex to design than C/S systems.

Prof. Majumdar CS 130 Lecture 5

Distributed object architecture

o1

o2

o3

o4

S (o1)

S (o2)

S (o3)

S (o4)

Objec t request broker

o5

o6

S (o5)

S (o6)

Prof. Majumdar CS 130 Lecture 5

Advantages
Can delay decisions on where and how services should
be provided
New resources to be added to it as required
Scaleable
Possible to reconfigure the system dynamically with
objects migrating across the network as required

Prof. Majumdar CS 130 Lecture 5

CORBA
CORBA is an international standard for an Object
Request Broker - middleware to manage
communications between distributed objects
Middleware for distributed computing is required at 2
levels:
At the logical communication level, the middleware allows
objects on different computers to exchange data and control
information;
At the component level, the middleware provides a basis for
developing compatible components. CORBA component
standards have been defined.
Prof. Majumdar CS 130 Lecture 5

CORBA application structure

Application
objects

Domain
facilities

Object request broker

CORBA services

Prof. Majumdar CS 130 Lecture 5

Horizontal C
ORBA
facilities

Service-oriented architectures
Based around the notion of externally
provided services (web services)
A web service is a standard approach to
making a reusable component available and
accessible across the web
A tax filing service could provide support for users
to fill in their tax forms and submit these to the
tax authorities
Prof. Majumdar CS 130 Lecture 5

Web services

Service
registry
Publish

Find

Service service
provider

Service
requestor
Bind

Prof. Majumdar CS 130 Lecture 5

Services and distributed objects


Provider independence
Public advertising of service availability
Opportunistic construction of new services through
composition (e.g., mashups)
Smaller, more compact, loosely coupled applications

Prof. Majumdar CS 130 Lecture 5

Services standards
Services are based on agreed, XML-based
standards so can be provided on any platform
and written in any programming language.
Key standards
SOAP - Simple Object Access Protocol;
WSDL - Web Services Description Language;
UDDI - Universal Description, Discovery and
Integration.

Prof. Majumdar CS 130 Lecture 5

Services scenario
An in-car information system provides drivers with
information on weather, road traffic conditions, local
information etc. This is linked to car radio so that
information is delivered as a signal on a specific radio
channel
The car is equipped with GPS receiver to discover its
position and, based on that position, the system
accesses a range of information services. Information
may be delivered in the drivers specified language.

Automotive system
Road traffic info
Weather
info

Facilities
info

gps coord

Road
locator
gps
coord

gps coord

Mobile Info Service


Translator

Info
stream

Language
info

Receiver
Receives
information stream
from services

Radio
Translates dig
ital
info stream to
radio signal

Traffic
info

Collates information

Service discovery
Finds available
services

command
gps coord
Transmitter
Sends position and
information request
to services

User interface
Receives request
from user

Locator
Discovers car
position
In-car software system

Next time
Design patterns

Prof. Majumdar CS 130 Lecture 5

You might also like