0% found this document useful (0 votes)
16 views47 pages

Week 11

Uploaded by

ahmedkingdom774
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views47 pages

Week 11

Uploaded by

ahmedkingdom774
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

Software Design and

Architecture
Software Architecture
Week 11
Architecture Styles
Objectives

 Explain important software architectures, their key


characteristics, and how they are used in practice,
which include:
 Language-based systems
 Repository-based systems
 Layered systems
 Interpreter-based systems
 Dataflow systems
 Implicit invocation systems
 Process control systems
Language-Based Systems

 The programming paradigm of the language selected to


implement a system will affect the architectural style
of that system.
 Object-oriented principles along with design patterns
lead to an object-oriented architectural style for the
system.
 Abstract Data Types and Object Oriented Design
 Main Program and Subroutine
Abstract Data Types and
Object Oriented Design
 Focused on the data.
 Begin by looking at the different kinds of data handled by
the system to see how the system can be broken down into
abstract data types.
 The classes within the system will determine the overall
structure of the system.
 The overall object-oriented architectural style of a system
directly follows from the fact that an object-oriented
approach was used in development.
 Some problems are well suited to an object-oriented
architectural style. However, not all situations will have
easily identifiable classes. In some situations, another
design choice may be better suited for the problem at hand.
Main Program and Subroutine

 Focused on functions.
 Develop from a procedural programming paradigm.
 C is an example of a language that follows this paradigm
 In a main program and subroutine architectural style, a
system is modeled by breaking up the overall
functionality of the system into a main program and
subroutines
 The main focus of this paradigm is therefore on the
behavior of functions and how data moves through those
functions.
 The main program and subroutine architectural style is
best suited for computation-focused systems.
Main Program and Subroutine
Repository-Based Systems

 This architecture allows data to be stored and shared


between multiple components, thus increasing the
maintainability, reusability, and scalability of the system.
 This architecture can be achieved by integrating a method
of shared data storage, such as a database, into the overall
system design.
 At the core of a data-centric architecture are two types of
components:
 Central data is the component used to store and serve data
across all components that connect to it.
 Data accessors are the components that connect to the
central data component. The data accessors make queries
and transactions against the information stored in the
database.
Repository-Based Systems
Repository-Based Systems

 Data accessors are separated from one another, and they


communicate only to the central data component.
 The central data shares data by saving the desired
information from the current state of the system and serving
data when requested.
 A data accessor contains all the business rules required to
perform its functions. This means that this software
architecture enables you to separate concerns into different,
specialized data accessors.
 Use of the data accessors can be controlled, so an end user
only has permission for the ones they need on a day-to-day
basis.
 Example of a Repository Based system is Blackboard
Architectural Style
Repository-Based Systems -
Advantages
 Data-centric architecture presents many advantages over a
basic object-oriented system, because of the integration of a
centralized database. These advantages include:
1. Increased support of data integrity, data backup, and data
restoration.
2. Reduced overhead for data transfer between data accessor, as
data accessors do not need to be concerned with talking to one
another—the database communicates for them,
3. A system that can be easily scaled up, as data accessors are
functionally independent, so additional features can be added
without having to worry about affecting others.
4. Central data components usually “live” on a separate server
machine with sufficient disk storage dedicated to the
database, which allow for easier management of information.
Repository-Based Systems -
Disadvantages
 Data-centric architecture also presents disadvantages.
Integrating a database can disadvantage a system in the
following ways:
1. The system is heavily reliant on the central data component, so
if it becomes unavailable or if the data corrupts, then the
entire system is affected. Safeguards such as data redundancies
that replicate data on separate hard disks can be costly.
2. Data accessors are dependent on what gets stored in the
database. New data accessors need to build around the existing
data schema. Anything that isn’t stored needs to be computed,
or if there is no matching column or table for a specific data
need, then the database cannot be used.
3. It is difficult to change the existing data schema, particularly if
a large amount of data is already stored. Further, data schema
changes will affect data accessors.
Blackboard Architectural
Style
 Developed for speech recognition applications in 1970s
 A number of components that act independently on the common data structure are
stored in the blackboard.
 In this style, the components interact only through the blackboard. The data-store
alerts the clients whenever there is a data-store change.
 The current state of the solution is stored in the blackboard and processing is
triggered by the state of the blackboard.
 The system sends notifications known as trigger and data to the clients when
changes occur in the data.
 This approach is found in certain AI applications and complex applications, such as
speech recognition, image recognition, security system, and business resource
management systems etc.
 If the current state of the central data structure is the main trigger of selecting
processes to execute, the repository can be a blackboard and this shared data
source is an active agent.
 A major difference with traditional database systems is that the invocation of
computational elements in a blackboard architecture is triggered by the current
state of the blackboard, and not by external inputs
Blackboard Architectural
Style
Layered Architecture

 In software, a layer is a collection of components that


work together towards a common purpose.
 The key characteristic of a layered architecture is that
the components in a layer only interact with components
in their own layer or adjacent layers.
 When an upper layer interacts with the layer directly
below it, it cannot see any of the deeper layers.
 The interfaces provided by the components of a layer
should be well defined and driven by the needs of the
system.
 Layering allows for applying “separation of concerns” into
each of the layers. Many layered systems are split into
“presentation,” “logic,” and “data” layers.
Layered Architecture
Layered Architecture

Students and the principal only interact


with one layer—the teachers, while
teachers interact with two adjacent layers
—students and the principal.
Layered Architecture

And of course, students interact with


other students
Advantages of Layered
Architecture
 Users can perform complex tasks without needing to
understand the layers below.
 Different layers can be run at different levels of
authorization or privilege. Typically, the top layer is
considered the “user space” that does not have
authority to allocate system resources or communicate
with hardware directly. This “sandboxing” provides
security and reliability to the kernel.
 Designs will be more loosely coupled, as layered
architecture follows the principle of least knowledge.
Trade-offs in Layered
Architecture
 Efficiency trade-off:
 If only adjacent layers can communicate, then the system
will likely have some interactions that pass through one
layer to the next, and sometimes information must be
shared between layers that are not adjacent. This extra
communication adds complexity and uses up processing
resources.
 Close vs Open Layers
Relaxed Layers
Client Server n-Tier

 n-Tier or multitier architectures are related to layered


architectures.
 Although the terms “tier” and “layer” are used
interchangeably, they are not the same thing.
 n-Tier or multitier architectures are layered
architectures based on tiers.
 Tiers refer to components that are typically on
different physical machines.
 The number of tiers in an n-Tier architecture can vary,
although three-tier and four-tier architectures are
common.
Client Server n-Tier

 The relationship between two adjacent tiers in an n-


Tier architecture is often a client/server relationship.
 In a client/server relationship, one program (the
server) provides services such as storing information in
a database or performing computation tasks upon
request from another program (the client).
 This communication is known as the request-response.
 A tier can act as both a server and a client
Example

Client Host

Server Host
Request-response

Synchronous
Or
Asynchronous

Limiting client/server relationships to request/response messaging


patterns allows for systems that can be scaled more easily by adding
clients.
Disadvantages of n-Tier
Architecture
 It requires extra resources to manage the client/server
relationships. If more tiers are added, there are more
machines or processes to manage, with different
communication protocols. This makes a system more
complex, and therefore more difficult to change and
maintain.
 A server acts as a central point of failure. Systems may
have backups or mirrors, but it can take time to switch
to these backups and recover the server. Redundant
servers are possible but add complexity.
Advantages of n-Tier
Architecture
 n-Tier architecture is very scalable. Clients can continue to be
added as long as a server can handle all the requests it receives
in a reasonable time.
 Centralization of functionality allow for data to reside on one
machine but to be accessible by any machine on the same
network.
 Centralization of computing power allows client machines to
require less processing power. Companies can thus offer
processing power as a service, which is more practical and cost
effective.
 n-Tier architecture supports separation of concerns. Middle
layers can take the role of managing application logic and
accessing the database directly. Adding tiers can further allow
for loose coupling and levels of abstraction, making a system
that is easier to change and extend.
Peer to Peer Pattern

 In this pattern, individual components are known


as peers. Peers may function both as a client,
requesting services from other peers, and as a server,
providing services to other peers. A peer may act as a
client or as a server or as both, and it can change its
role dynamically with time.
 Example: Napster
Interpreter based systems

 In some software systems, users can write scripts,


macros, or rules that access and compose the basic
features of the system in new ways. E.g. Excel
 Interpreter-based systems allow end users to write
scripts, macros, or rules that access, compose, and run
the basic features of those systems in new and dynamic
ways.
 It provides users with flexible and portable functionality
that can be applicable in a variety of commercial
systems.
Interpreter based systems-
Advantages
 Interpreters make systems more portable, so they can
work on platforms that the interpreter supports.
 This is an important feature with the growth of virtual
machines and virtual environments—more and more
services are being hosted in the cloud.
Interpreter based systems-
Disadvantages
 Interpreters can be slow. Basic implementations spend
little time analyzing the source code and use a line-by-
line translate and execute strategy.
 This is a trade-off: it may be faster and more flexible
for developers and end users to use an interpreted
language, but slower for computers to execute
interpreted code.
Interpreter based systems-
Uses
 Database query languages such as SQL, cypher etc.
 Java Virtual Machines
Dataflow Systems

 In data flow architecture, the whole software system is


seen as a series of transformations on consecutive
pieces or set of input data, where data and operations
are independent of each other.
 In this approach, the data enters into the system and
then flows through the modules one at a time until they
are assigned to some final destination (output or a data
store).
 The connections between the components or modules
may be implemented as I/O stream, I/O buffers, piped,
or other types of connections.
Dataflow Systems

 The data can be flown in the graph topology with


cycles, in a linear structure without cycles, or in a tree
type structure.
 It is suitable for applications that involve a well-defined
series of independent data transformations or
computations on orderly defined input and output such
as compilers and business data processing applications.
Execution system between modules:
 Batch sequential
 Pipe and filter or non-sequential pipeline mode
Batch Sequential

Batch Sequential can be used in Financial Applications


Batch Sequential

 Advantages
 Provides simpler divisions on subsystems.
 Each subsystem can be an independent program working
on input data and producing output data.
 Disadvantages
 Provides high latency and low throughput.
 Does not provide concurrency and interactive interface.
 External control is required for implementation.
Pipes and Filters

Active Filters vs Passive filters

The order in which the filters transform data may change the end result.
This is similar to mathematics—the order in which addition or
multiplication occurs in an expression can change the end result.
Pipes and Filters

 Advantages
 Provides concurrency and high throughput for excessive data processing.
 Provides reusability and simplifies system maintenance.
 Provides modifiability and low coupling between filters.
 Provides flexibility by supporting both sequential and parallel
execution.
 Disadvantages
 Not suitable for dynamic interactions.
 Overhead of data transformation between filters.
 Does not provide a way for filters to cooperatively interact to solve a
problem.
 Example
 Pipe and filter architectures are popular in use, such as in the UNIX
operating system for text-based utilities.
Implicit Invocation Systems

 In implicit invocation systems, functions are not in


direct communication with each other.
 The event-based architectural style is one design for
such a system. This style derives from the event-driven
programming paradigm.
Event Based Architectural
Style
 Functions are not explicitly called.
 Instead, event consumers are based on events sent from
event generators.
 Event-based functions experience implicit invocation,
where communication between functions is mediated by
an event bus.
 An event bus is the connector between all event
generators and consumers in the system.
Event Based Architectural
Style
 To achieve this structure, an event and an event
consumer must be bound via an event bus.
 This means that each event consumer registers with the
event bus to be notified of certain events.
 When the event bus detects an event, it distributes the
event to all appropriate event consumers.
 The event bus is a critical part of the system. The
observer design pattern actually manifests the event-
based architectural style.
Event Based Architectural
Style
Event Based Architectural
Style
 This pattern primarily deals with events and has 4 major
components; event source, event
listener, channel and event bus. Sources publish
messages to particular channels on an event bus.
Listeners subscribe to particular channels. Listeners are
notified of messages that are published to a channel to
which they have subscribed before.
 Usage:
 Mobile app development
 Event based Game development
Process Control Systems

 Process control is important in many processes to ensure


efficient and safe operations.
 Feedback Loops
 A feedback loop is one of the most basic forms of process
control. It has four basic components:
 a sensor,
 a controller,
 an actuator,
 and the process itself. The sensor monitors some kind of
important information. The controller is the logic of the
system. The actuator is the physical method of manipulating
the process. The process is what is trying to be controlled.
Feedback Loop - Example

 Consider controlling room temperature. This is a


feedback loop.
 A thermostat acts as a sensor for the room’s
temperature.
 The software is the controller.
 The heating vent in the room is the physical means to
manipulating the process.
 The room temperature is the process.
Feedforward – open loop

 A feedback loop is an example of a closed loop, as


information from the process is used to control the
same process.
 An open loop is one where the process is controlled
without monitoring the process.
 Feedforward control occurs in systems with processes
in series. Information from an upstream process can be
used to control a downstream process.
Feedforward control-example

 A flood protection system could use feedforward


control.
 If an upstream monitoring station detects large flow
rates, then the controller for the flood protection
system could be signalled.
 The controller asks the actuator, a gate, to open and
divert water into a reservoir to keep water levels
manageable.

You might also like