Lecture 3 - Architectural Styles
Lecture 3 - Architectural Styles
Architectural Styles
MAIN CONTENT
Type of connectors
(e.g. calls, pipes, inheritance, event broadcast)
Common architectural design
Component Based
Structure Layered
Object-oriented
Architecture styles
Overall system organization:
Hierarchical
Client-server
Cloud-based
Peer-to-peer
Individual program structuring:
Control-based
• Call-and-return (Subroutine-based)
• Coroutine-based
Dataflow:
• Pipes and filters
• Blackboard
• Event-driven
Object-oriented
Hierarchical
Example
Communication protocols
Operating systems
Hierarchical
Components
Group of subtasks which implement an abstraction
at some layer in the hierarchy
Connectors
Protocols that define how the layers interact
Hierarchical: examples
The operating system
The OSI Networking Model
OSI: Open Systems Interconnection
Each level supports communication at a level of
abstraction
Protocol specifies behavior at each level of
abstraction
Each layer deals with specific level of communication
and uses services of the next lower level
Weaknesses:
Performance overhead from going through layers
Strict discipline often bypassed in practice
Client-server
Components
Subsystems, designed as independent processes
Each server provides specific services, e.g. printing,
database access
Clients use these services
Connectors
Data streams, typically over a communication
network
Client
Client Network Server
Client
Client-server example: databases
Clients: user applications
Customized user interface
Front-end processing of data
Initiation of server remote procedure calls
Access to database server across the network
Weaknesses:
Data interchange can be hampered by different data
layouts
Communication may be expensive
Data integrity functionality must be implemented for
each server
Single point of failure
Client-server variant: cloud computing
Advantages:
Scalability
Many issues such as security, availability, reliability
are handled centrally
Disadvantages:
Loss of control
Dependency on Internet
Peer-to-peer
Similar to client-server style, but each component is both
client and server
Examples
File sharing applications, e.g., Napster
Communication and collaboration, e.g., Skype
Peer-to-peer: Evaluation
Strengths:
Efficiency: all clients provide resources
Scalability: system capacity grows with number of clients
Robustness
• Data is replicated over peers
• No single point of failure (in pure peer-to-peer
style)
Weaknesses:
Architectural complexity
Resources are distributed and not always available
More demanding of peers (compared to client-server)
New technology not fully understood
Call-and-return
Components: Objects
Connectors: Messages (routine invocations)
Key aspects
Object preserves integrity of representation
(encapsulation)
Representation is hidden from client objects
Variations
Objects as concurrent tasks
Call-and-return: Evaluation
Strengths:
Change implementation without affecting clients
Can break problems into interacting agents
Can distribute across multiple machines or networks
Weaknesses:
Objects must know their interaction partners; when partner
changes, clients must change
Side effects: if A uses B and C uses B, then C’s effects on B
can be unexpected to A
Subroutines
Functional decomposition
Topmost functional abstraction
B C D
E1 I I1 C2 I2
Subroutines: Evaluation
Strengths:
Clear, well-understood decomposition
Based on analysis of system’s function
Supports top-down development
Weaknesses:
Tends to focus on just one function
Downplays the role of data
Strict master-slave relationship; subroutine loses
context each time it terminates
Adapted to the design of individual functional
pieces, not entire system
Coroutines
Variations:
Control: push versus pull
Degree of concurrency
Topology
Dataflow: batch-sequential
Component
Batch-sequential
Examples
Payroll computations
Tax reports
Dataflow: pipe-and-filter
Component: filter
Reads input stream (or streams)
Locally transforms data
Produces output stream (s)
Connector: pipe
stream, e.g., FIFO buffer Pipe
Filter
Filter Filter Filter
Filter
Pipe-and-filter
Data processed incrementally as it arrives
Output can begin before input fully consumed
Examples
lex/yacc-based compiler (scan, parse, generate…)
Unix pipes
Image / signal processing
Pipe-and-filter: Evaluation
Strengths:
Reuse: any two filters can be connected if they agree on
data format
Ease of maintenance: filters can be added or replaced
Potential for parallelism: filters implemented as separate
tasks, consuming and producing data incrementally
Weaknesses:
Sharing global data expensive or limiting
Scheme is highly dependent on order of filters
Can be difficult to design incremental filters
Not appropriate for interactive applications
Error handling difficult: what if an intermediate filter
crashes?
Data type must be greatest common denominator, e.g. ASCII
Dataflow: event-based (publish-subscribe)
A component may:
Announce events
Routine
Register a callback
for events of other
Routine
components
Examples
Programming environment tool integration
User interfaces (Model-View-Controller)
Syntax-directed editors to support incremental
semantic checking
Event-based style: example
Weaknesses:
Loss of control:
What components will respond to an event?
In which order will components be invoked?
Are invoked components finished?
Correctness hard to ensure: depends on context and
order of invocation
Data-centered (repository)
Components
Central data store component represents state
Independent components operate on data store
Knowledge Direct
Source access
Repository Knowledge
Source
Knowledge
Source Computation
Data-centered: Evaluation
Strengths:
Efficient way to share large amounts of data
Data integrity localized to repository module
Weaknesses:
Subsystems must agree (i.e., compromise) on a
repository data model
Schema evolution is difficult and expensive
Distribution can be a problem
Blackboard architecture
Example
Repository: modern compilers act on shared data:
symbol table, abstract syntax tree
Blackboard: signal and speech processing
Interpreters
for MDE
Definitions according toMDA
• System: The subject of any MDA specification (program, computer system,
federation of systems)
• Solution Space: The spectrum of possible solutions that satisfy the reqs.
and the rules for the interactions of the parts using the connectors
concerns
• View: A model of a system seen under a specific viewpoint
Specification of
structure and
behavior of a
system, abstracted
from technological
details
transactions
Some typical examples of middleware
• Transaction-processing monitors
• Database middleware
• Web middleware
Transaction-processing monitors
requesting client
program and the
databases, it ensures
that all databases are
updated properly
Database middleware