SlideShare a Scribd company logo
3
Most read
4
Most read
13
Most read
Chain of Responsibility
From Definition to Implementation
Mudasir Qazi - mudasirqazi00@gmail.com 116-Dec-14
Contents / Agenda
• Definition
• Advantages and Usage
• UML Diagram
• Sequence Diagram
• Daily life Examples
• Implementation – Scenario UML
• Implementation – Steps 1 to 4
• Results
Mudasir Qazi - mudasirqazi00@gmail.com 216-Dec-14
Definition
1. Avoid coupling the sender of a request to its receiver by giving
multiple objects a chance to handle the request.
2. We can say that normally each receiver contains reference of another
receiver. If one object cannot handle the request then it passes the
same to the next receiver and so on.
3. Chain the receiving objects and pass the request along the chain until
an object handles it.
• It comes under the “Behavioral Design Patterns”.
Mudasir Qazi - mudasirqazi00@gmail.com 316-Dec-14
Advantages and Usage
• Advantages:
1. It reduces the coupling.
2. It adds flexibility while assigning the responsibilities to objects.
3. It allows a set of classes to act as one, events produced in one class can be sent
to other handler classes with the help of composition.
• Usage:
1. When more than one object can handle a request and the handler is unknown.
2. When the group of objects that can handle the request must be specified in
dynamic way.
Mudasir Qazi - mudasirqazi00@gmail.com 416-Dec-14
UML Diagram
Client’s Request comes to
the (abstract) handler and
it decides that which of the
(concrete) sub handlers will
actually full fil the request.
If request is not completed
by first assigned sub
handler then it returns it to
the base handler and it
decides which of the sub
handlers is now feasible for
task.
Mudasir Qazi - mudasirqazi00@gmail.com 516-Dec-14
UML – Sequence Diagram
Mudasir Qazi - mudasirqazi00@gmail.com 616-Dec-14
Examples
1. Leave Application Example:
Lets say we have an organization where Team members when apply for leave, the request goes to
the Team Leader. Team leader can approve all the leave request of less than 10 days. If the leave
request is of more than 10 days then the request will be passed on to the Project Leader. Project
leader is able to approve leaves of up to 20 days. If the leave is applied for more than 20 days then
this requests will be passed to the HR. HR can approve up to 30 days of leave. If the leave is of
more than 30 days then the leave application cannot be approved by the system and it needs a
manual process for approval.
2. Loan Approval Example:
In a bank where the approval route for mortgage applications are from the bank manager to the
director then to the vice president, where the approval limits are:
Manager – 0 to 100k
Director – 100k to 250k
Vice President – anything above 250k
We will pass the request to the manager until the application is processed.
Mudasir Qazi - mudasirqazi00@gmail.com 716-Dec-14
Implementation – Loan Approval Example
• We are going to implement loan approval example like discussed above. Following is its UML Diagram.
Approving Limits:
Manager – 0 to 100k
Director – 100k to 250k
Vice President – anything above 250k
Mudasir Qazi - mudasirqazi00@gmail.com 816-Dec-14
Step 1 : Loan Class
Our Loan class contains an integer to hold loan
amount, a getter property and a constructor
working as a setter method.
Mudasir Qazi - mudasirqazi00@gmail.com 916-Dec-14
Step 2 : Main Handler (abstract)
This class is going to act as main request handler, every request
form client will be accepted by this and then this will pass request
to its subclasses.
Mudasir Qazi - mudasirqazi00@gmail.com 1016-Dec-14
Step 3 : Concrete Classes
Note: All these classes are inherited form our
LoanApprover abstract class. And implements
the ApproveLoan method with respect to
their expectations.
Mudasir Qazi - mudasirqazi00@gmail.com 1116-Dec-14
Step 4 : Testing
We created three object to test with different
amounts. Then we have to tell the hierarchy
by SetNextApprover method.
Mudasir Qazi - mudasirqazi00@gmail.com 1216-Dec-14
Step 5 : Results
• Here are results as we expected.
Mudasir Qazi - mudasirqazi00@gmail.com 1316-Dec-14

More Related Content

PPT
Excel Básico
DOC
PPT
Facade pattern
PDF
Báo cáo đồ án tôt nghiệp: Xây dựng Website bán hàng thông minh
PDF
Giáo trình mạng máy tính PTIT
PPTX
Big Data ppt
PPTX
Decorator Pattern
PDF
Pseudocódigo ou Portugol (Lógica de Programação)
Excel Básico
Facade pattern
Báo cáo đồ án tôt nghiệp: Xây dựng Website bán hàng thông minh
Giáo trình mạng máy tính PTIT
Big Data ppt
Decorator Pattern
Pseudocódigo ou Portugol (Lógica de Programação)

What's hot (20)

PPT
Chain of responsibility
PPTX
Chain of Responsibility Pattern
PDF
Remote Method Invocation in JAVA
PPTX
Chain of responsibility pattern
PPTX
Remote Method Invocation (Java RMI)
PPTX
Proxy Design Pattern
PPT
Story Cards
PPT
Adapter pattern
PDF
Introduction to apache kafka, confluent and why they matter
PPT
Design patterns ppt
PPT
10 component diagram
PPTX
Adbms 43 multiversion concurrency control
PPTX
Timestamp protocols
PDF
Collaboration diagram- UML diagram
PPTX
AWS Simple Storage Service (s3)
PDF
CORBA - Introduction and Details
PPT
Proxy pattern
PPTX
Static dynamic and active web pages
PPTX
Let us understand design pattern
PDF
Deadlock in Distributed Systems
Chain of responsibility
Chain of Responsibility Pattern
Remote Method Invocation in JAVA
Chain of responsibility pattern
Remote Method Invocation (Java RMI)
Proxy Design Pattern
Story Cards
Adapter pattern
Introduction to apache kafka, confluent and why they matter
Design patterns ppt
10 component diagram
Adbms 43 multiversion concurrency control
Timestamp protocols
Collaboration diagram- UML diagram
AWS Simple Storage Service (s3)
CORBA - Introduction and Details
Proxy pattern
Static dynamic and active web pages
Let us understand design pattern
Deadlock in Distributed Systems
Ad

Similar to Design Pattern - Chain of Responsibility (20)

PPTX
Design pattern - Facade Pattern
PPTX
CH02-1Chapter 1___Business Modeling.pptx
DOC
JACKY KUMAR
PPTX
Project Plan And Estimation
DOC
Mohamed .doc
PDF
PSMA - Gestione Missioni DIAG
DOCX
Assignment Help Moodle Monkey
PPSX
Non functional performance requirements v2.2
PPTX
OOP - Understanding association, aggregation, composition and dependency
PDF
Development Framework method (Agile project analysis)
DOC
Groom Auto Project
PPTX
Toronto ACE Sept 2022.pptx
PDF
Kseniya Leshchenko: Shared development support service model as the way to ma...
PPTX
Алексей Денисюк "When Agile doesn't work. Tips and Tricks"
PPTX
Agile Development with Agile Contract
PDF
Cognitive 544 pa_art
PDF
MWLUG 2017: Best Practices before, during, and after moving to IBM SmartCloud...
PDF
Agile Guru - Agile Culture, Management Best Practices and App Dev Practices
PDF
Project Administration Proposal Template PowerPoint Presentation Slides
PDF
FM Engineer CV working with Wasl group...
Design pattern - Facade Pattern
CH02-1Chapter 1___Business Modeling.pptx
JACKY KUMAR
Project Plan And Estimation
Mohamed .doc
PSMA - Gestione Missioni DIAG
Assignment Help Moodle Monkey
Non functional performance requirements v2.2
OOP - Understanding association, aggregation, composition and dependency
Development Framework method (Agile project analysis)
Groom Auto Project
Toronto ACE Sept 2022.pptx
Kseniya Leshchenko: Shared development support service model as the way to ma...
Алексей Денисюк "When Agile doesn't work. Tips and Tricks"
Agile Development with Agile Contract
Cognitive 544 pa_art
MWLUG 2017: Best Practices before, during, and after moving to IBM SmartCloud...
Agile Guru - Agile Culture, Management Best Practices and App Dev Practices
Project Administration Proposal Template PowerPoint Presentation Slides
FM Engineer CV working with Wasl group...
Ad

More from Mudasir Qazi (12)

PPTX
Design Patterns - Abstract Factory Pattern
PPTX
Database - SQL Joins
PPTX
Database - Normalization
PPTX
Database - Entity Relationship Diagram (ERD)
PPTX
OOP - Polymorphism
PPTX
OOP - Java is pass-by-value
PPTX
OOP - Benefits and advantages of OOP
PPTX
Design Pattern - Singleton Pattern
PPTX
Design Pattern - Observer Pattern
PPTX
Design Pattern - MVC, MVP and MVVM
PPTX
Design Pattern - Introduction
PPTX
Design Pattern - Factory Method Pattern
Design Patterns - Abstract Factory Pattern
Database - SQL Joins
Database - Normalization
Database - Entity Relationship Diagram (ERD)
OOP - Polymorphism
OOP - Java is pass-by-value
OOP - Benefits and advantages of OOP
Design Pattern - Singleton Pattern
Design Pattern - Observer Pattern
Design Pattern - MVC, MVP and MVVM
Design Pattern - Introduction
Design Pattern - Factory Method Pattern

Recently uploaded (20)

PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT
Project quality management in manufacturing
PPTX
Welding lecture in detail for understanding
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Geodesy 1.pptx...............................................
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
composite construction of structures.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
Mechanical Engineering MATERIALS Selection
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Project quality management in manufacturing
Welding lecture in detail for understanding
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
additive manufacturing of ss316l using mig welding
Geodesy 1.pptx...............................................
Lecture Notes Electrical Wiring System Components
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Automation-in-Manufacturing-Chapter-Introduction.pdf
composite construction of structures.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Internet of Things (IOT) - A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Mechanical Engineering MATERIALS Selection
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Operating System & Kernel Study Guide-1 - converted.pdf

Design Pattern - Chain of Responsibility

  • 1. Chain of Responsibility From Definition to Implementation Mudasir Qazi - mudasirqazi00@gmail.com 116-Dec-14
  • 2. Contents / Agenda • Definition • Advantages and Usage • UML Diagram • Sequence Diagram • Daily life Examples • Implementation – Scenario UML • Implementation – Steps 1 to 4 • Results Mudasir Qazi - mudasirqazi00@gmail.com 216-Dec-14
  • 3. Definition 1. Avoid coupling the sender of a request to its receiver by giving multiple objects a chance to handle the request. 2. We can say that normally each receiver contains reference of another receiver. If one object cannot handle the request then it passes the same to the next receiver and so on. 3. Chain the receiving objects and pass the request along the chain until an object handles it. • It comes under the “Behavioral Design Patterns”. Mudasir Qazi - mudasirqazi00@gmail.com 316-Dec-14
  • 4. Advantages and Usage • Advantages: 1. It reduces the coupling. 2. It adds flexibility while assigning the responsibilities to objects. 3. It allows a set of classes to act as one, events produced in one class can be sent to other handler classes with the help of composition. • Usage: 1. When more than one object can handle a request and the handler is unknown. 2. When the group of objects that can handle the request must be specified in dynamic way. Mudasir Qazi - mudasirqazi00@gmail.com 416-Dec-14
  • 5. UML Diagram Client’s Request comes to the (abstract) handler and it decides that which of the (concrete) sub handlers will actually full fil the request. If request is not completed by first assigned sub handler then it returns it to the base handler and it decides which of the sub handlers is now feasible for task. Mudasir Qazi - mudasirqazi00@gmail.com 516-Dec-14
  • 6. UML – Sequence Diagram Mudasir Qazi - mudasirqazi00@gmail.com 616-Dec-14
  • 7. Examples 1. Leave Application Example: Lets say we have an organization where Team members when apply for leave, the request goes to the Team Leader. Team leader can approve all the leave request of less than 10 days. If the leave request is of more than 10 days then the request will be passed on to the Project Leader. Project leader is able to approve leaves of up to 20 days. If the leave is applied for more than 20 days then this requests will be passed to the HR. HR can approve up to 30 days of leave. If the leave is of more than 30 days then the leave application cannot be approved by the system and it needs a manual process for approval. 2. Loan Approval Example: In a bank where the approval route for mortgage applications are from the bank manager to the director then to the vice president, where the approval limits are: Manager – 0 to 100k Director – 100k to 250k Vice President – anything above 250k We will pass the request to the manager until the application is processed. Mudasir Qazi - mudasirqazi00@gmail.com 716-Dec-14
  • 8. Implementation – Loan Approval Example • We are going to implement loan approval example like discussed above. Following is its UML Diagram. Approving Limits: Manager – 0 to 100k Director – 100k to 250k Vice President – anything above 250k Mudasir Qazi - mudasirqazi00@gmail.com 816-Dec-14
  • 9. Step 1 : Loan Class Our Loan class contains an integer to hold loan amount, a getter property and a constructor working as a setter method. Mudasir Qazi - mudasirqazi00@gmail.com 916-Dec-14
  • 10. Step 2 : Main Handler (abstract) This class is going to act as main request handler, every request form client will be accepted by this and then this will pass request to its subclasses. Mudasir Qazi - mudasirqazi00@gmail.com 1016-Dec-14
  • 11. Step 3 : Concrete Classes Note: All these classes are inherited form our LoanApprover abstract class. And implements the ApproveLoan method with respect to their expectations. Mudasir Qazi - mudasirqazi00@gmail.com 1116-Dec-14
  • 12. Step 4 : Testing We created three object to test with different amounts. Then we have to tell the hierarchy by SetNextApprover method. Mudasir Qazi - mudasirqazi00@gmail.com 1216-Dec-14
  • 13. Step 5 : Results • Here are results as we expected. Mudasir Qazi - mudasirqazi00@gmail.com 1316-Dec-14