Unit 2 SADP
Unit 2 SADP
Introduction
Architectural patterns express fundamental structural organization
schemas for software systems.
They provide a set of predefined subsystems, specify their responsibilities, and
include rules and guidelines for organizing the relationships between them
Architectural patterns represent the highest-level patterns in our pattern
system
Each architectural pattern helps to achieve a specific global system
property, such as the adaptability of the user interface
We group our patterns into four categories
1. From Mud to Structure
2. Distributed Systems
3. Interactive Systems
4. Adaptable Systems
Introduction : From Mud to Structure
Allows controlled decomposition of an overall system task into cooperating subtasks.
Example: Layering, Pipes and Filters, Blackboard Architecture.
Layers
The Layers architectural pattern helps to structure applications that can be decomposed into groups of
subtasks in which each group of subtasks is at a particular level of abstraction.
Pipes an Filters
The Pipes and Filters architectural pattern provides a structure for systems that process a stream of data.
Each processing step is encapsulated in a filter component.
Data is passed through the pipes between adjacent filters.
Recombining filters allows to build families of related systems.
Blackboard
The Blackboard architectural pattern is useful for problems for which no deterministic solution strategies
is known.
In Blackboard several specialized subsystems assemble their knowledge to build a possibly partial or
approximate solution.
Introduction : Distributed Systems
Example: Broker pattern provides the complete infrastructure for distributed
applications.
Micro-kernel and Pipes and Filters are two other patterns referred to by this
category.
Broker
It can be used to structure distributed software systems with decoupled
components that interact by remote service invocations. A broker component is
responsible for coordinating communication, such as forwarding requests as well as
for transmitting results and exceptions.
Introduction : Interactive Systems
It features human-computer interaction.
Example: MVC, Presentation-Abstraction Control Pattern.
Model-View-Controller
It divides an interactive application into three components. The model contains the core functionality
and data. Views display information to the user. Controllers handle user input. Views and controllers
together forms the user interface. A change propagation mechanism ensures consistency between the
user interface and the model.
Presentation-Abstraction-Control
It defines a structure for interactive software systems in the form of a hierarchy of cooperating agents.
Every agent is responsible for a specific aspect of the application's functionality and consists of three
components: presentation, abstraction and control. This subdivision separates the human computer
interaction aspects of the agent from its functional core and its communication with the other agents.
Introduction : Adaptable Systems
They support extension of applications and their adaptation to evolving technology.
Example: Reflection and Microkernel pattern.
Microkernel
This pattern applies to software systems that must be able to adapt to changing system requirements. It
separates a minimal functional core from extended functionality and customer-specific parts. The micro-kernel
also serves as a socket for plugging in these extensions and coordinating their collaboration.
Reflection
This pattern provides a mechanism changing the structure and behavior of software systems dynamically.
It supports the modification of fundamental aspects, such as type structures and function call mechanisms.
In this pattern, an application is split into two parts.
A meta level provides information about selected system properties and makes the software self-aware.
A base level includes the application logic.
Its implementation builds on the meta level. Changes to information kept in the meta level affect
subsequent base-level behavior.
Introduction : From Mud to Structure
Layered Architecture It helps to structure applications that can be
decomposed into groups of tasks
Blackboard It is useful for problems for which no deterministic
solution is known
Pipes and Filters It provides a structure for systems that process a
stream of data
Introduction : From Mud to Structure
Layers : The layers architectural pattern
helps to structure applications that can be
decomposed into groups of subtasks in
which each group of subtasks is at a
particular level of abstraction
Networking protocols are probably the
best-known example of layered
architectures
Introduction : From Mud to Structure
It organizes the system as groups of tasks
Each group of task is at a particular level of abstraction (layer)
Each layer
… is client of the lower layer
… provides services to the upper layer
Introduction : From Mud to Structure
The protocol specifies agreements at a variety of abstraction levels,
ranging from the details of bit transmission to high-level application logic
A layered approach is considered better practice than implementing the
protocol as a monolithic block
Introduction : From Mud to Structure
Context: A large system that requires decomposition
Problem: Imagine that you are designing a system whose dominant
characteristic is a mix of low- and high-level issues, where high-level
operations rely on the lower-level ones.
Introduction : From Mud to Structure
Need to balance the following forces
Late source code changes should not ripple through the system
Interfaces should be stable. and may even be prescribed by a standards body
Parts of the system should be exchangeable.
Components should be able to be replaced by alternative implementations without
affecting the rest of the system
It may be necessary to build other systems at a later date with the same low-
level issues as the system you are currently designing
Introduction : From Mud to Structure
Similar responsibilities should be grouped to help understandability
and maintainability
There is no 'standard' component granularity
Complex components need further decomposition
Crossing component boundaries may impede performance
The system will be built by a team of programmers, and work has to be
subdivided along clear boundaries requirement that is often overlooked
at the architectural design stage
Introduction : From Mud to Structure
Solution
Introduction : From Mud to Structure
Solution
Introduction : From Mud to Structure
Solution
Introduction : From Mud to Structure
Dynamics :
Scenario I : A client Issues a request to Layer N. Since Layer N cannot
carry out the request on its own
Scenario II : illustrates bottom-up communication, chain of actions starts
at Layer 1, for example when a device driver detects input
Scenario III : situation where requests only travel through a subset of the
layers
Introduction : From Mud to Structure
Dynamics
Scenario IV : situation similar to Scenario III. An event is detected in Layer
1, but stops at Layer 3 instead of traveling all the way up to Layer N (re-
send request)
Scenario V : involves two stacks of N layers communicating with each
other
Introduction : From Mud to Structure
Implementation : step-wise refinement approach to the definition of a
layered architecture
This is not necessarily the best method for all applications-often a
bottom-up or 'yo-yo' approach is better.
Not all the following steps are mandatory-it depends on your application
Introduction : From Mud to Structure
Define the abstraction criterion for grouping tasks into layers
Determine the number of abstraction levels according to your abstraction criterion
Name the layers and assign tasks to each of them
Specify the services
Refine the layering
Specify an interface for each layer
Sstructure individual layers
Specify the communication between adjacent layers.
Decouple adjacent layers
Design an error-handling strategy
Introduction : From Mud to Structure
Introduction : From Mud to Structure
Variants:
Relaxed Layered System : less restrictive about the relationship between layers, UNIX operating
system or the X Window System
Layering Through Inheritance : object-oriented systems, lower layers are implemented as base classes
Known Uses:
Virtual Machines that insulates higher levels from low-level details or varying hardware.
APIs is a layer that encapsulates lower layers of frequently-used functionality
Information Systems (IS) Presentation, Application logic, Domain layer, Database
Windows NT System services, Resource management layer, Kernel, HAL and Hardware
Introduction : From Mud to Structure
Consequences:
The Layers pattern has several benefits
Reuse of layers
Support for standardization
Dependencies are kept local
Exchangeability
Credits:
Introduction : Pipes and Filters
The Pipes and Filters architectural pattern provides a structure for systems that process a stream of data. Each
processing step is encapsulated in a filter component.
Data is passed through pipes between adjacent filters. Recombining filters allows you to build families of
related systems
Introduction : Pipes and Filters
Context: Processing data streams
Problem: Imagine you are building a system that must process or transform a stream
of input data
Introduction : Pipes and Filters
Consider the following forces
Future system enhancements should be possible by exchanging processing steps or by
recombination of steps, even by users.
Small processing steps are easier to reuse in different contexts than large components.
Non-adjacent processing steps do not share information.
Different sources of input data exist, such as a network connection or a hardware sensor providing
temperature readings, for example.
It should be possible to present or store final results in various ways.
Explicit storage of intermediate results for further processing in files clutters directories and is
error-prone, if done by users.
You may not want to rule out multi-processing the steps, for example running them in parallel or
quasi-parallel.
Introduction : Pipes and Filters
Solution:
The Pipes and Filters architectural pattern divides the task of a system into several sequential
processing steps. These steps are connected by the data flow through the system-the output data of a
step is the input to the subsequent step
The input to the system is provided by a data source such as a text file.
The output flows into a data sink such as a file, terminal, animation program and so on.
The data source, the filters and the data sink are connected sequentially by pipes.
Each pipe implements the data flow between adjacent processing steps.
The sequence of filters combined by pipes is called a processing pipeline.
Introduction : Pipes and Filters
Structure:
Filter components are the processing units of the pipeline
A concrete filter implementation may combine any of these three basic principles
The activity of a filter can be triggered by several events:
The subsequent pipeline element pulls output data from the filter.
The previous pipeline element pushes new input data to the filter.
Most commonly, the filter is active in a loop, pulling its input from and pushing its output down the
pipeline.
The first two cases denote so-called passive filters, whereas the last case is an active filter. An active
filter starts processing on its own as a separate program or thread.
A passive filter component is activated by being called either as a function (pull) or as a procedure
(push)
Introduction : Pipes and Filters
Pipes denote the connections between filters, between the data source and the first
filter, and between the last filter and the data sink
Introduction : Pipes and Filters
The data sink collects the results from the end of the pipeline. Two variants of the
data sink are possible
An active data sink pulls results out of the preceding processing stage, while a
passive one allows the preceding filter to push or write the results into it
Introduction : Pipes and Filters
Introduction : Pipes and Filters
Dynamics:
Scenario I shows a push pipeline in which activity starts with the data source. Filter activity is
triggered by writing data to the passive filters.
Introduction : Pipes and Filters
Dynamics:
Scenario II shows a pull pipeline. Here control flow is started by the data sink calling for data
Introduction : Pipes and Filters
Dynamics:
Scenario III shows a mixed push-pull pipeline with passive data source and sink. Here the second
filter plays the active role and starts the processing.
Introduction : Pipes and Filters
Dynamics:
Scenario IV shows a more complex but typical behavior of a Pipes and Filters system
Introduction : Pipes and Filters
Dynamics:
Scenario IV shows a more complex but typical behavior of a Pipes and Filters system
Introduction : Pipes and Filters
Implementation:
You can use a system service such as message queues or UNIX pipes for pipe
connections, or other options like the direct call implementation, as described in
steps 3 through 6 below
1. Divide the system's task into a sequence of processing stages
2. Define the data format to be passed along each pipe
3. Decide how to implement each pipe connection
4. Design and implement the filters.
5. Design the error handling
6. Set up the processing pipeline
Introduction : Pipes and Filters
Example resolved:
We did not follow the Pipes and Filters pattern strictly in our Mocha compiler by implementing all phases of
the compiler as separate filter programs connected by pipes
Introduction : Pipes and Filters
Variants:
Tee and join pipeline systems, The single-input single-output filter specification of the Pipes and
Filters pattern can be varied to allow filters with more than one input and/or more than one output
cat file I tee pipeA I sort -u I comm -13 - pipeB
Introduction : Pipes and Filters
Known Uses:
UNIX
CMS Pipelines
LASSPTools
Consequences:
The Pipes and Filters architectural pattern has the following benefits
1. No intermediate files necessary, but possible
2. Flexibility by filter exchange
3. Flexibility by recombination
4. Reuse of filter components
5. Rapid prototyping of pipelines
6. Efficiency by parallel processing
Introduction : Pipes and Filters
Applying the Pipes and Filters pattern imposes some liabilities
1. Sharing state information is expensive or inflexible
2. Efficiency gain by parallel processing is often an illusion
1. The cost for transferring data between filters may be relatively high compared to the cost of
the computation carried out by a single filter
2. Some filters consume all their input before producing any output, either because the task,
such as sorting, requires it or because the filter is badly coded
3. Context-switching between threads or processes is generally an expensive operation on a
single-processor machine
4. Synchronization of filters via pipes may stop and start filters often, especially when a pipe
has only a small buffer
3. Data transformation overhead
4. Error handling.
Introduction : Pipes and Filters
See Also:
The Layers pattern is better suited to systems that require reliable operation,
because it is easier to implement error handling than with Pipes and Filters
Credits:
This pattern relies on experience we gained when learning, using, and teaching
UNIX. Our thanks therefore go to the designers of the first versions of UNIX, and its
predecessors, who invented and established the use of pipes and filters
Introduction : Blackboard
The Blackboard architectural pattern is useful for problems for which no
deterministic solution strategies are known.
In Blackboard several specialized subsystems assemble their knowledge to build
a possibly partial or approximate solution
Introduction : Blackboard
Example: Software system for speech recognition
The input to the system is speech recorded as a waveform.
The system not only accepts single words, but also whole sentences that are
restricted to the syntax and vocabulary needed for a specific application, such as a
database query
The desired output is a machine representation of the corresponding English
phrases. The transformations involved require acoustic- phonetic, linguistic. and
statistical expertise
Introduction : Blackboard
The input is the waveform at the bottom, and the output consists of the phrase ‘are any by Feigenbaum’
Introduction : Blackboard
Context:
An immature domain in which no closed approach to a solution is known or feasible
Problem:
The Blackboard pattern tackles problems that do not have a feasible deterministic solution for the
transformation of raw data into high-level data structures, such as diagrams, tables or English
phrases.
Vision, image recognition, speech recognition and surveillance are examples of domains in which
such problems occur
Introduction : Blackboard
The following forces influence solutions to problems of this kind
1. A complete search of the solution space is not feasible in a reasonable time
2. Since the domain is immature, you may need to experiment with different algorithms for the
same subtask
3. There are different algorithms that solve partial problems
4. Input, as well as intermediate and final results, have different representations, and the
algorithms are implemented according to different paradigms
5. An algorithm usually works on the results of other algorithms
6. Uncertain data and approximate solutions are involved
7. Employing disjoint algorithms induces potential parallelism. If possible you should avoid a strictly
sequential solution
Introduction : Blackboard
This type of expert system structure is inadequate for a speech recognition
system.
During the problem-solving process, the system works with partial solutions that
are combined, changed or rejected
The name 'blackboard’ was chosen because it is reminiscent of the situation in
which human experts sit in front of a real blackboard and work together to
solve a problem
Introduction : Blackboard
Structure:
Divide your system into a component called blackboard, a collection of knowledge sources, and a
control component
The blackboard is the central data store. Elements of the solution space and control data are stored
here
All elements of the solution space can appear on the blackboard.
For solutions that are constructed during the problem solving process and put on the blackboard,
we use the terms hypothesis or blackboard entry
A hypothesis usually has several attributes, for example its abstraction level, that is, its conceptual
distance from the input
2. The Microkernel pattern applies to software systems that must be able to adapt
to changing system requirements
3. The Broker pattern can be used to structure distributed software systems with
decoupled components that interact by remote service invocations.
A broker component is responsible for coordinating communication, such as
forwarding requests, as well as for transmitting results and exceptions
Introduction : Distributed Systems
Three groups of developers who can benefit by using the Broker
pattern:
1. Those working with an existing Broker system who are interested in
understanding the architecture of such systems.
2. Those who want to build 'lean' versions of a Broker system, without all the bells
and whistles of a full-blown OLE(Object Linking and Embedding) or CORBA (Common Object
Request Broker Architecture).
3. Those who plan to implement a fully-fledged Broker system, and therefore need
an in-depth description of the Broker architecture
Introduction : Distributed Systems
The Broker Pattern is a design pattern used in software engineering to facilitate
communication and interaction between components or services in a distributed
system. In this pattern, a central component called the “broker” acts as an
intermediary or middleman, facilitating communication and coordination
between other components or services.
The Broker receives requests from clients, processes them, and dispatches them
to the appropriate components or services based on predefined rules or criteria.
Context:
Your environment is a distributed and possibly heterogeneous system with independent
cooperating components
Problem:
Building a complex software system as a set of decoupled and inter-operating components, rather
than as a monolithic application, results in greater flexibility, maintainability and changeability
Introduction : Distributed Systems
Components should be able to access services provided by others through remote, location-
transparent service invocations.
You need to exchange, add, or remove components at run-time.
The architecture should hide system- and implementation-specific details from the users of
components and services.
Introduction : Distributed Systems
Variants:
Direct Communication Broker System
Message Passing Broker System
Trader System
Adapter Broker System
Callback Broker System
Known Uses:
CORBA
IBM SOM/DSOM
Microsoft's OLE 2.x
The World Wide Web
ATM-P
Introduction : Distributed Systems
Consequences:
Location Transparency clients do not need to know where servers are located
Changeability and extensibility of components If servers change but their interfaces remain
the same, it has no functional impact on clients
Portability of a Broker system The Broker system hides operating sys- tem and network
system details from clients and servers by using indirection layers such as APIs, proxies and
bridges
Interoperability between different Broker systems Different Broker systems may interoperate
if they understand a common protocol for the exchange of messages
Reusability When building new client applications, you can often base the functionality of
your application on existing services
Some liabilities:
Restricted efficiency slow in application
Lower fault tolerance server or a broker fails, unable to continue successfully
Introduction : Distributed Systems
See also:
Credits:
Introduction : Interactive Systems
We describe two patterns that provide a fundamental structural organization for interactive
software systems
The Model-View-Controller architectural pattern (MVC) divides an interactive application into three
components.
The model contains the core functionality and data.
Views display information to the user.
Controllers handle user input.
Views and controllers together comprise the user interface.
A change-propagation mechanism ensures consistency between the user interface and the model
Introduction : Interactive Systems
Model-View-Controller:
Example:
A Simple Information System for political elections with proportional representation
Introduction : Interactive Systems
Model-View-Controller:
Context:
Interactive applications with a flexible human-computer interface
Problem:
Building a system with the required flexibility is expensive and error prone if the
user interface is tightly interwoven with the functional ore.
Introduction : Interactive Systems
Model-View-Controller:
The same information is presented differently in different windows, for example, in a bar chart or
pie chart.
The display and behavior of the application must reflect data manipulations immediately.
Changes to the user interface should be easy, and even possible at run-time.
Supporting different 'look and feel' standards or porting the user interface should not affect code
in the core of the application.
Introduction : Interactive Systems
Model-View-Controller:
Solution :
MVC divides an interactive application into the three areas: processing, output, and input
Known Uses:
Smalltalk
MFC
ET++
Introduction : Interactive Systems
Model-View-Controller:
Model-View-Controller has several benefits:
1. Multiple views of the same model
2. Synchronized views
3. 'Pluggable' views and controllers
4. Exchangeability of 'look and feel'.
5. Framework potential