0% found this document useful (0 votes)
10 views

Week 13-Software Architecture and Patterns

Uploaded by

Zubair Afridi
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)
10 views

Week 13-Software Architecture and Patterns

Uploaded by

Zubair Afridi
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/ 19

Software Architecture And

Design Patterns

Dr. Huma Hayat Khan


Architecture VS Design
• Architecture comes in Designing phase and Design Patterns comes in Building phase.

• Architectural pattern is like a blue print and design pattern is actual implementation.

• Architecture is base which everything else adhere to and design pattern is a way to structure
classes to solve common problems.

• Architecture pattern: how components should behave and communicate in the system, set the
physical location of components and finally choose the tools in order to create components.

• Design pattern: while architecture deals more with the wide picture, design should drill down into
the details relating to implementing certain components. Designing of components end up with
classes, interfaces, abstract classes and other OO feature in order to fulfil the given component
tasks.
Architecture
Design Patterns
Patterns
-Gangs of Four (GoF) Design Patterns
1. Layered pattern Creational- The design patterns that deal with the creation of an
2. Client-server object. e.g Singleton, Factory, Abstract Factory, Builder, and
pattern Prototype.
3. Master-slave Structural- The design patterns in this category deals with how
pattern different objects and classes can be combined together to make a
4. Pipe-filter pattern bigger structure such as Inheritance and Composition. e.g. Adapter,
Composite, Proxy, Flyweight,Facade, Bridge, and Decorator
5. Model-view-
controller pattern Behavioral-This type of design patterns provide solution for the
better interaction between objects, how to provide lose coupling, and
flexibility to extend easily in future. E.g. Template Method,
Mediator,Chain of Responsibility, Observer, Strategy, Command etc.
Architectural Patterns
1. Layered pattern
• This pattern is also known as n-tier architecture pattern.
• It can be used to structure programs that can be decomposed into
groups of subtasks, each of which is at a particular level of abstraction.
• Each layer provides services to the next higher layer.

Usage
• General desktop applications.
• E commerce web applications.
Common layers of a general information system

• Presentation layer (also known as UI layer)


• Application/business logic layer (also known
as service/domain layer)
• Data access layer (also known as persistence layer)
• DataBase Layer
Layered pattern Solution
• Customer screen receives a request to get a
customer information for a particular individual.
• It forwards that request to customer delegate
component/module. This module is responsible
in knowing which modules in the business layer
can process that request.
• So customer object will get all the information
regarding customer. This will call Customer and
Order Dao (Data Access Object). These will in
turn execute the SQL statements to retrieve the
corresponding data and pass it back.
Layered Architecture for Library Management
System- Example
• 1. Presentation Layer: The Presentation Layer is the user interface where librarians and library
patrons interact with the system. It includes the graphical user interfaces and client-side
components.
• Librarian Dashboard:
• Librarians access a web-based dashboard to manage the library system.
• Functionalities include adding new books, updating catalog information, and managing
user accounts.
• Provides insights into library analytics and reports.
• User Portal:
• Library patrons use a web or mobile interface to browse the catalog, check book
availability, and manage their accounts.
• Allows users to search for books, view borrowing history, and place book requests.
2. Application Layer: The Application Layer contains the core business logic, processing
user requests, managing data, and enforcing library policies.
• Library Management Server:
• Implements business logic for book cataloging, user management, and
borrowing/returning books.
• Manages user authentication and authorization.
• Coordinates communication between the Presentation Layer and the Data Layer.
• Business Logic:
• Manages the book catalog, including details such as title, author, and availability
status.
• Implements user authentication, account management, and borrowing policies.
• Generates reports on book circulation, overdue fines, and other relevant metrics.
3. Data Layer: The Data Layer is responsible for storing and retrieving data. It
includes the database and any necessary data storage systems.
• Relational Database:
• Stores persistent data such as book details, user profiles, borrowing
history, and library policies.
• Supports efficient querying for quick data retrieval.
• Ensures data integrity through normalization and relationships.
• Data Access Layer:
• Manages communication between the Application Layer and the
database.
• Executes SQL queries and updates data based on requests from the
Application Layer.
• Optimizes database interactions for performance.
2. Client-server pattern
• This pattern consists of two parties;
• a server and
• multiple clients.
• The server component will provide services to multiple client components.
• Clients request services from the server and the server provides relevant services
to those clients.
• The server continues to listen to client requests.
• This architecture is used when the client and server are connected via internet.
Usage
• Online applications such as email, document sharing and banking.
Cont…
• Server can be placed in a local area network (LAN) or in the internet.
• If LAN then outsiders can not access the severs but insider can.
• There are some methods to deploy the servers.
• On-Premise (Deployed within an organisation)
• Cloud ( IAAS)
3. Master-slave pattern
• This pattern consists of two parties;
• master and
• slaves.
• The master component distributes the work among identical slave
components, and computes a final result from the results which the slaves
return.

Usage
• In database replication, the master database is regarded as the authoritative
source, and the slave databases are synchronized to it.
• Master slave is a way to optimise the I/O in your
application other then using caching.

• The master database serves as the keeper of the


information. The true data is kept at the master
database, thus writing only occurs there.

• Reading on the other hand is only done at the


slaves.

• The architecture serves the purpose of


safeguarding site reliability. If a site recieves a lot of
traffic and the only available database is one
master, it will be overloaded with reading and
writing requests. Making the entire system slow for
everyone on the site.
4. Pipe-filter pattern
• This pattern can be used to structure systems which produce and process a stream of data.
• Each processing step is enclosed within a filter component.
• Data to be processed is passed through pipes.
• These pipes can be used for buffering or for synchronization purposes.
• It is an architecture pattern for stream processing. It consist of one or more components called
‘Filters’.
• These filters will transform or filter the data and pass it on via connectors called ‘Pipes’.
• These ‘filters’ that merely consume or produce data are Functions like sorting and counting.
• All the filters can work at same time. Also every Pipe connected to the filter has its own role in the
function of the filter.

Usage
• Compilers. The consecutive filters perform lexical analysis, parsing, semantic analysis, and code
generation.
• When data is produced and sent from the producer ‘PUMP’, it goes through the pipes and filters
and arrives at the destination ‘SINK’

• PUMP can be a static text file or a keyboard input.


• SINK can be a file, database or a computer screen.
6. Model-view-controller pattern
• This pattern, also known as MVC pattern, divides an interactive application in to 3
parts as,
• model — contains the core functionality and data
• view — displays the information to the user (more than one view may be defined)
• controller — handles the input from the user
• This is done to separate internal representations of information from the ways
information is presented to, and accepted from, the user. It decouples components
and allows efficient code reuse.

Usage
• Architecture for World Wide Web applications in major programming languages.
Generic MVC Sequence Diagram: Example

You might also like