Lecture 3 - Software Architecture - 2
Lecture 3 - Software Architecture - 2
Lecture 3
A Software Architecture
• An architecture is an abstraction of a
is an Abstraction
system that suppresses details of
components that do not affect how
they:
– Use
– Are used by
– Relate to
– Interact with
…other components.
Externally Visible
Properties of
• Components
Externally visible properties refers
to those assumptions other
components can make of a
component, such as:
– Provided services
– Performance characteristics
– Fault handling
– Shared resource usage
– Etc.
Software Architecture
styles
• Architecture styles - A set of design rules that identify the
kinds of components and connectors that may be used to
compose a system or subsystem, together with local or
global constraints on the way the composition is done’
• Architectural Styles of Software Systems:
– Repository-Subsystems access and modify data from a
single data structure called the repository.
– Pipe and Filter-
• Case Study of Compiler Architecture
• architectural style to divide a larger processing task into a
sequence of smaller, independent processing steps (Filters) that
are connected by channels (Pipes).
– Object-Oriented- focused on modeling a business domain
and defining business objects based on entities within the
business domain.
Software Architecture
styles
– Implicit Invocation-
• instead of invoking a procedure directly, a
component can announce (or broadcast) one or
more events.
• Other components in the system can
register an interest in an event by
associating a procedure with the event.
• When the event is announced the system
itself invokes all of the procedures that have
been registered for the event.
• Thus an event 'implicitly' causes the
invocation of procedures in other modules."
Software Architecture
styles
– Layered
• A layered system is organized hierarchically, each
layer serving the layer above. In some systems, inner
layers are hidden in all but the adjacent outer layer.
– Interpreter
– Process-Control
– Client/Server
Can a system have
more that one
• structure?
Yes, no one structure holds the claim to
being the architecture.
• Below are some examples of structures:
– Module decomposition
– Objects and message passing at runtime
– Build dependencies
– Etc.
Does Every System have
an Architecture?
• Yes.
• For small systems the architecture
may be trivial.
• For large systems it definitely
exists in the software product, but
may not have been documented.
Why is Software Architecture
Important?
• Communication among stakeholders:
– Customers, managers, designers, programmers.
Development
Logical View
View
Business
Scenarios Analysts
Integrators Infrastructure
Engineers
• Why scenarios:
– A mechanism to discover the key
architectural elements and
connectors
– Validation of the architecture design
after the other views are created
– Addresses the concerns of both the
functional and non-functional
requirements
State of Practice
• There is not currently a well-defined
terminology or notation to characterize
architectural structures.
• However, good software engineers make
common use of architectural principles
when designing software.
• These principles represent rules of thumb
or patterns that have emerged informally
over time. Others are more carefully
documented as industry standards.
Architectural Styles
of Software Systems
Style
An architectural style represents a family of
related systems
Defines the design vocabulary (and
constraints) for the components, connectors,
ports, roles, bindings and properties.
Architectural Styles of
Software Systems
• An Architectural Style defines a family
of systems in terms of a pattern of
structural organization. It determines:
– the vocabulary of components and
connectors that can be used in instances of
that style
– a set of constraints on how they can be
combined. For example, one might
constrain:
• the topology of the descriptions (e.g., no cycles).
• execution semantics (e.g., processes execute in
parallel).
Determining an
•
Architectural Style
We can understand what a style is by
answering the following questions:
– What is the structural pattern?
(i.e., components, connectors, constraints)
– What is the underlying computational
model?
– What are the essential invariants of the
style?
– What are some common examples of its use?
– What are the advantages and
disadvantages of using that style?
– What are some of the common
specializations of that style?
Repository Style
Computation
Shared Data
Memory
Repository Style
Specializations
• Changes to the data structure
trigger computations.
• Data structure in memory
(persistent option).
• Data structure on disk.
• Concurrent computations and data
accesses.
Repository Style
Examples
• Information Systems
• Programming Environments
• Graphical Editors
• AI Knowledge Bases
• Reverse Engineering Systems
Repository Style
Advantages
• Efficient way to store large
amounts of data.
• Sharing model is published as the
repository schema.
• Centralized management:
– backup
– security
– concurrency control
Repository Style
Disadvantages
• Must agree on a data model a
priority.
• Difficult to distribute data.
• Data evolution is expensive.
Object-Oriented Style
object
obj obj
obj
obj
obj
obj
Me obj
th od
inv obj
oc
ati
o n
Object-Oriented
Invariants
• Objects are responsible for
preserving the integrity (e.g.,
some invariant) of the data
representation.
• The data representation is hidden
from other objects.
Object-Oriented
Specializations
• Distributed Objects
• Objects with Multiple Interfaces
Object-Oriented
Advantages
• Because an object hides its data
representation from its clients, it
is possible to change the
implementation without
affecting those clients.
• Can design systems as collections
of autonomous interacting agents.
Object-Oriented
Disadvantages
• In order for one object to interact with
another object (via a method invocation)
the first object must know the identity
of the second object.
– Contrast with Pipe and Filter Style.
– When the identity of an object changes, it is
necessary to modify all objects that invoke it.
• Objects cause side effect problems:
– E.g., A and B both use object C, then B’s
effects on C look like unexpected side effects
to A.
Pipe and Filter
Architectural Style
• Suitable for applications that
require a defined series of
independent computations to be
performed on data.
• A component reads streams of
data as input and produces
streams of data as output.
Pipe and Filter
Architectural Style
• (Cont’d)
Components: called filters, apply
local transformations to their input
streams and often do their computing
incrementally so that output begins
before all input is consumed.
• Connectors: called pipes, serve as
conduits or channels for the streams,
transmitting outputs of one filter to
inputs of another filter.
Pipe and Filter
Architectural Style
filter
(Cont’d)
pipes
Pipe and Filter
Invariants
• Filters do not share state with
other filters.
• Filters do not know the identity
of their upstream or downstream
filters.
Pipe and Filter
Specializations
• Pipelines: Restricts topologies to
linear sequences of filters.
• Batch Sequential: A degenerate
case of a pipeline architecture
where each filter processes all of
its input data before producing
any output.
Pipe and Filter
Examples
• Unix Shell Scripts: Provides a notation
for connecting Unix processes via pipes.
– cat file | grep Erroll | wc -l
• Traditional Compilers: Compilation
phases are pipelined, though the phases
are not always incremental. The phases
in the pipeline include:
– lexical analysis + parsing + semantic
analysis + code generation
Pipe and Filter
Advantages
• Easy to understand the overall
input/output behavior of a system as
a simple composition of the
behaviors of the individual filters.
• They support reuse, since any two
filters can be hooked together,
provided they agree on the data that
is being transmitted between them.
Pipe and Filter
Advantages (Cont’d)
• Systems can be easily maintained
and enhanced, since new filters can be
added to existing systems and old filters
can be replaced by improved ones.
• They permit certain kinds of
specialized analysis, such as
throughput and deadlock analysis.
• The naturally support concurrent
execution.
Pipe and Filter
Disadvantages
• Not good choice for interactive
systems, because of their
transformational character.
• Excessive parsing and unparsing
leads to loss of performance and
increased complexity in writing
the filters themselves.
Client-Server Style
• Suitable for applications that involve
distributed data and processing across
a range of components.
• Components:
– Servers: Stand-alone components that
provide specific services such as printing,
data management, etc.
– Clients: Components that call on the
services provided by servers.
• Connector: The network, which allows
clients to access remote servers.
Client-Server Style
Network
Client Server
Client Server
Object X Object Y
Code Data call foo call foo Data Data
call foo on on
Object X Object Y Code Code
execute foo
Broadcasting System
Implicit Invocation
Invariants
• Announcers of events do not know
which components will be affected by
those events.
• Components cannot make
assumptions about the order of
processing.
• Components cannot make
assumptions about what processing
will occur as a result of their events
(perhaps no component will respond).
Implicit Invocation
Specializations
• Often connectors in an implicit
invocation system include the
traditional procedure call in
addition to the bindings between
event announcements and
procedure calls.
Implicit Invocation
Examples
• Used in programming
environments to integrate tools:
– Debugger stops at a breakpoint and
makes that announcement.
– Editor responds to the announcement
by scrolling to the appropriate source
line of the program and highlighting
that line.
Implicit Invocation
Examples (Cont’d)
• Used to enforce integrity
constraints in database
management systems (called
triggers).
• Used in user interfaces to
separate the presentation of data
from the applications that manage
that data.
Implicit Invocation
Advantages
• Provides strong support for reuse since
any component can be introduced into
a system simply by registering it for the
events of that system.
• Eases system evolution since
components may be replaced by other
components without affecting the
interfaces of other components in the
system.
Implicit Invocation
Disadvantages
• When a component announces an
event:
– it has no idea what other components
will respond to it,
– it cannot rely on the order in which
the responses are invoked
– it cannot know when responses are
finished
Layered Style
Useful System
sets of
procedures
Basic Utilities
Core Layer
procedure
calls
Layered Style
Specializations
• Often exceptions are made to
permit non-adjacent layers to
communicate directly.
– This is usually done for efficiency
reasons.
Layered Style Examples
• Layered Communication
Protocols:
– Each layer provides a substrate for
communication at some level of
abstraction.
– Lower levels define lower levels of
interaction, the lowest level being
hardware connections (physical layer).
• Operating Systems
– Unix
Unix Layered Architecture
Plain Cooked
Socket
File Cooked Raw Raw TTY
Block Block TTY
File Interface Interface Interface Line
Protocols System Disc.
Network
Block Device Driver Character Device Driver
Interface
Hardware
Layered Style
Advantages
• Design: based on increasing
levels of abstraction.
• Enhancement: Changes to the
function of one layer affects at
most two other layers.
• Reuse: Different implementations
(with identical interfaces) of the
same layer can be used
interchangeably.
Layered Style
Disadvantages
• Not all systems are easily
structured in a layered fashion.
• Performance requirements may
force the coupling of high-level
functions to their lower-level
implementations.
Interpreter Style
Current State
inputs Program
of
Being
Program Being
Interpreted
Interpreted
Computation
State Machine store
selected
outputs instruction Current
Execution State of
Engine Execution
Selected Engine
data (fetch)
Interpreter Style
Examples
• Programming Language
Compilers:
– Java
– Smalltalk
• Rule Based Systems:
– Prolog
– Coral
• Scripting Languages:
– Awk
– Perl
Interpreter Style
Advantages
• Simulation of non-implemented
hardware.
• Facilitates portability of
application or languages across a
variety of platforms.
Java Architecture
Java Bytecode
Source Verifier
Code
Class
Loader
Java Interpreter
Compiler
INTERNET Run-time
Environment
Java Hardware
Bytecode
Interpreter Style
Disadvantages
• Extra level of indirection slows
down execution.
• Java has an option to compile
code.
– JIT (Just In Time) compiler.
Technologies for Distributed
Architectures
IBM’s MQSeries
Queue Manager
put get
A B
Queue
Programs
Communicating via a
•
Queue on the Same
Figure illustrates two programs A and B
Workstation
that are communicating
managed message queue.
through a
Transmission Queue
Channel
Queue Manager
get
B
Queue
Programs
Communicating via a
• Queue
Figure on two
illustrates Different
programs A
and B that are communicating
Workstations
through a managed message queue.
• A,B are executing on different
workstations.
• Program A puts a message onto the
queue, specifying not a local queue
but a local definition of a remote
queue.
Programs
Communicating via a
Queue on Different
• The local queue definition identifies a non-
Workstations
local queue that is managed by another
queue manager.
• The queue manager, to which program A
is connected to, puts the message on a
special queue called a transmission queue.
Trigger
Client
Request Queue
Manager
(QM) S1
Data
(Response)
R
Scaling-Up to Multiple Queues
and Services
Q1
Trigger
Q2 S1
Client Data
Requests Trigger (Response)
Queue
Manager S2
(QM)
Data
R (Response)
Q3
S3
Trigger
CORBA
• The Common Object Request
Broker Architecture (CORBA) is a
standard defined by the Object
Management Group (OMG) that
enables software components written
in multiple computer languages and
running on multiple computers to
work together (i.e., it
supports multiple platforms)
CORBA Messages
Adapter
(CORBA OBJECT)
ORB
Object Adapters in
CORBA
• The Figure shows how an adapter can
act as a proxy between a set of services
and the ORB.
• Clients will access each service through
the adapter that is responsible for that
service.
• The adapter will be responsible for
finding the appropriate filters to handle
each client request.
Object Adapters in CORBA
(Cont’d)
• These filters may be:
– on the same machine as the adapter,
– or may be on another machine, in
which case the adapter must
delegate the client request to another
adapter.
CORBA architecture
Client
objects
Server objects
Object
adapter
Interface
CORBA services
repository