Professional Documents
Culture Documents
1
Introduction
Over the years a lot of experience has been
gained
Certain patterns and structures appear very often
Therefore architectural patterns are discovered,
not invented
Vocabulary is used by designers to think and talk
about the architectural design
An architectural style is a particular pattern that
focuses on the large-scale structure of a system
typically described by the common vocabulary
Software Architecture: Foundations, Theory, and Practice; Richard N. Taylor, Nenad Medvidovic,
and Eric M. Dashofy; © 2008 John Wiley & Sons, Inc. Reprinted with permission. 3
Architectural Patterns
4
Architectural Styles
An architectural style is a named collection of
architectural design decisions that
are applicable in a given development context
6
Basic Properties of Styles
A vocabulary of design elements
Component and connector types; data elements
Visualizations
Style-specific depictions matching engineers’ mental
models
8
Some Common Styles
“Basic” styles
Pipe and filter (data-flow style)
Object-oriented (traditional, language-influenced styles)
Layered
Blackboard (Shared memory)
State transition
Client-server (Layered)
Peer-to-peer
Event-based (a.k.a. Implicit invocation)
Publish-Subscribe
Mobile-code (interpreter)
“Derived” styles
Koala
CORBA
Pipe and Filter Style
Components are filters
Processing units
Transform input data streams into output data streams
Possibly incremental production of output
Connectors are pipes
Channels for data streams
Input Circular Output
Medium Input Shift Alphabetizer Output Medium
Style invariants
Filters are independent (no shared state)
Filter has no knowledge of up- and down-stream filters
Example:
UNIX shell
Pipe and Filter Style
11
Example: UNIX/LINUX
Linux has a lot of filter commands like awk, grep, sed, spell, and wc. A filter takes
input from one command, does some processing, and gives output.
cat sample
Bat
Goat
Apple
Dog
First
Eat
Hide
Highlight only the lines that do not contain the character ‘a’, and the result should
be in reverse order.
cat sample | grep –v a | sort – r
Hide
First
Dog
Apple
*The grep command - to find strings and values in a text document
https://www.guru99.com/linux-pipe-grep.html 12
Pipe and Filter Style (cont.)
Advantages
System behavior is a succession of component behaviors
Filter addition, replacement, and reuse (possible to hook
Disadvantages
Often lead to batch processing
Poor for interactive applications
14
Object-Oriented Style
Style invariants
Objects are responsible for their internal representation
integrity
Internal representation is hidden from other objects
Advantages
Because an object hides its data representation from its
Disadvantages
Objects must know identities of servers/other objects to
interact
Inefficient for high performance applications
Object-Oriented Style (cont.)
Object-Oriented Style (cont.)
17
Layered Style
Hierarchical system organization
“Multi-level client-server”
Each layer exposes an “API” (interface) to be
used by above layers
Each layer acts as a
Server: service provider to layers “above”
Client: service consumer from layers “below”
Connectors are protocols of layer interaction
Layered Style (cont.)
Summary:
An ordered sequence of layers,
each layer offers services
(interfaces) that can be used by
programs (components) residing
with the layer(s) above it.
Design Elements:
- Components: layers
- Connectors: typically method or
procedure calls
- Data: parameters passed
between layers
Topology:
Linear (strict layering), acyclic Example
(non-strict layering)
Layered Style (cont.)
Examples
Layered Style (cont.)
Advantages
Increasing abstraction levels
Evolvability
Advantages
Data centralization, powerful server serving many
clients
Disadvantages
Single point of failure
Network bandwith/amount of requests
Blackboard – manages
central data
Knowledge source –
evaluates its own
applicability, computes a
result, update blackboard
Control – monitors
blackboard, schedules
knowledge source activations
27
HEARSAY II used a blackboard architecture to recognize human speech.
28
Blackboard Style (cont.)
Example
A distributed computing model for a metaphor describing how people
work together to collaboratively solve a problem around a blackboard
29
Blackboard Style (cont.)
Advantages
Solution strategies should not preplanned
Data/problem determine the solutions
Disadvantages
Overhead when a straight-forward solution
strategy is available
Interaction between “independent” programs need
a complex regulation
Data on the blackboard is a subject to frequent
change (and requires propagation to all other
components)
30
Implicit Invocation Style
Event announcement instead of method invocation
“Listeners” register interest in & associate methods with
events
System invokes all registered methods implicitly
Style invariants
“Announcers” are unaware of their events’ effects, if any
Components that wish to act as listeners are registered to listen for certain events at configuration time (by
specification in an XML file, for instance). When an event is triggered, all registered listeners of that event are
passed the event by means of a dynamically determined method call. In this way, functions are implicitly 32
invoked. This process of notifying listeners of an event is called event announcement.
Publish-Subscribe Style
Distinguished from pull-based (e.g., the Web)
Subscribers register/deregister to receive specific
messages or specific content. Publishers broadcast
messages to subscribers either synchronously or
asynchronously.
Publish-Subscribe Style (cont.)
Summary:
Subscribers register/deregister to receive specific messages or
specific content. Publishers broadcast messages to subscribers
synchronously or asynchronously.
Design Elements:
Components: publishers, subscribers, proxies for managing
distribution
Connectors: typically a network protocol is required.
Topology:
Example
Peer-to-Peer Style (cont.)
Advantages
Robustness (if a node is not available the
functionality is taken over)
Scalability
Decentralization
Disadvantages
Security (peers might be malicious)
Latency (when information retrieval time is
crucial)
Mobile-Code Style
Sometimes interpretation/computation cannot be
performed locally, variants:
code-on-demand
Client has resources & processing power; server has code
to be executed. Client requests the code from server and
runs it locally
An example - a web server sending the html & javascript
code to a home computer, which have access to resources
like cookies and the users screen.
remote evaluation -
Client has code but don’t have resources to execute
mobile agent
Initiator has code and some resources
Can autonomously decide to migrate to a different node to
obtain additional resources
Mobile-Code Style
Summary:
Enable code to be transmitted to a remote host for computation.
Reason: lack of local computing power, lack of resources, or data
sets remotely located.
Design elements:
Components: “Execution dock” (which handles receipt and
deployment of code and state), code compiler/interpreter
Connectors: Network protocols and elements for packaging
code and data for transmission.
Data : representations of code as data; program state; data
Topology:
network
Mobile-Code Style (cont.)
Advantages
Dynamic adaptability
Performance (resources)
Disadvantages
Security Code being executed might be
malicious
Network/transmission costs
41
Mobile-Code Style (cont.)
Heterogeneous Styles
The architecture of a software system is almost never limited to a
single architectural style but is often a combination of architectural
styles that form the complete system.
Example
Main program and Object-oriented
subroutines
Virtual
Traditional machines
Language-
Influenced Styles
Peer-to-
Peer Layered Client-
server
Event-based
Architectural
Styles Batch-
Implicit sequential
Invocation
Dataflow
Styles
Publish-subscribe Interpreter
Shared Pipe-and-filter
Memory
Mobile
Basic Rule- Blackboard
Code
Interpreter based 44
Reference:
45
MVC architecture pattern
Widely used for the UI of an application, well
suited to web applications and other types of
application executes application logic to
select the appropriate view and
sends it the information that it
needs to render the UI
46
MVC in action – Spring MVC
47
Spring MVC
Web Browser sends request to Dispatcher Servlet ask Handler Mapping to identify which Controller to process
the request. Handler Mapping inform and Dispatcher Servlet sent request to corresponding Controller. Controller
process the request and create a model & view (e.g., employeelist) and sent to Dispatcher Servlet. Dispatcher
Servlet gives view name to View Resolver to get actual view location. View resolver identify location and sends
the extension to Dispatcher Servlet. Dispatcher Servlet sends the model & view to View Engine. The View Engine
merge the model and view template and produce HTML and sent back to Dispatcher Servlet to be sent back to
Web Browser
Source: https://www.youtube.com/watch?v=Cu3mHxv8-To
48
Example: N-Tier Client Server Style
Separation of concerns:
Presentation, business and data
handling logic are clearly Client Web Web Web
partitioned in different tiers. Tier Client Client Client
Synchronous
communications: Web Server
Communications between tiers Web Server
Tier
is synchronous request-reply.
Each tier waits for a response
from the other tier before Business
Application Server
Logic Tier
proceeding.
Flexible deployment: There
are no restrictions on how a Data
Management Databases
multi-tier application is deployed. Tier
All tiers could run on the same
machine, or each tier may be
deployed on its own machine.
49
Example
50
N-Tier Client Server – Quality Attribute Analysis
Quality Issues
Attribute
Availability Servers in each tier can be replicated, so that if one fails, others remain available.
Overall the application will provide a lower quality of service until the failed
server is restored.
Failure handling If a client is communicating with a server that fails, most web and application
servers implement transparent failover. This means a client request is, without its
knowledge, redirected to a live replica server that can satisfy the request.
Modifiability Separation of concerns enhances modifiability, as the presentation, business and
data management logic are all clearly encapsulated. Each can have its internal
logic modified in many cases without changes rippling into other tiers.
Performance This architecture has proven high performance. Key issues to consider are the
amount of concurrent threads supported in each server, the speed of connections
between tiers and the amount of data that is transferred. As always with
distributed systems, it makes sense to minimize the calls needed between tiers to
fulfill each request.
Scalability As servers in each tier can be replicated, and multiple server instances run on the
same or different servers, the architecture scales out and up well. In practice, the
data management tier often becomes a bottleneck on the capacity of a system.
51
Architecting Modern Applications
Cyber-Physical Systems (CPS)
Cloud-based Applications
Mobile Applications – e.g., Fitness app, Grab, Food
Panda, FlexiParking,..etc.
Social Media – e.g., IG, FB, Twitter..
Internet-of-Things (IoT) – e.g., smart home, smart office,
etc.
Big Data application – e.g., fraud detection, market
analysis
…..
Microservice Architecture
Serverless Architecture
…
52