SlideShare una empresa de Scribd logo
1 de 19
Chain of Responsibility
GoF Behavioral Design Pattern
Scenario: User Authentication
Using email/password

Using Local Network Login/pass

Authentication Module

Using Remote login/pass
Let’s code!
This mass is available at https://gist.github.com/hlegius/e1a721ebbc7de2a91fb1
Code Review
•
•
•
•
•
•
•

We got a Service class;
Skinny Controllers;
Meaningful (and cool) names;
No temp variable;
Short methods;
A lot of non-sense `ifs` statements;
(Very) Complicated logic. (WTF award!)
So, let’s go forward on that ?
WTF dude!?

Wrong design decision indicator!

This mass is available at https://gist.github.com/hlegius/e1a721ebbc7de2a91fb1
Chain of Responsibility
• Decouple client from receivers when you got
more than one object that can handle it;
• Giving you the chance to test each part
(sender and receivers) in isolated.
• Create one point of change if new Receiver
arrives.
• Added flexibility in assigning responsibilities to
objects;
• Boost your code readability like a boss.
This code is available at https://gist.github.com/hlegius/7188168
This code is available at https://gist.github.com/hlegius/7188168
This code is available at https://gist.github.com/hlegius/7188168
Chain of Responsibility
Bad Consequences
• More Lines of Code than first version;
• Complex if you have one or two fixes
receivers;
• Receipt is not guaranteed that will be
handled;
Known Uses
• Handle Events – Also known as “Event
Handler” or “Responder”
• ET++ used Chain of Responsibility to handle
Graphical Updates. (Took from GoF book)
Macro point of view - UML

Client

UserAuthenticator

Handler

Authenticator <abstract>

ConcreteHandler1

EmailAuthenticator

ConcreteHandler2

NetworkAuthenticator

ConcreteHandler3

PartnerAuthenticator
Don't get me wrong!

You can apply this with
PHP, Python, Ruby and so on.
Thank you!

http://programe.me

Reference: GoF book

Más contenido relacionado

La actualidad más candente

Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceDavid Hoerster
 
Production - Designing for Testability
Production - Designing for TestabilityProduction - Designing for Testability
Production - Designing for TestabilityMichael Bryzek
 
CloudFest 2018 Hackathon Project Results Presentation - CFHack18
CloudFest 2018 Hackathon Project Results Presentation - CFHack18CloudFest 2018 Hackathon Project Results Presentation - CFHack18
CloudFest 2018 Hackathon Project Results Presentation - CFHack18Jeffrey J. Hardy
 
When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?Niklas Heidloff
 
Building Autonomous Services
Building Autonomous ServicesBuilding Autonomous Services
Building Autonomous ServicesMatthias Noback
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developersAidan Casey
 
OSMC 2021 | Contributing to open source with the example of icinga (1)
OSMC 2021 | Contributing to open source with the example of icinga (1)OSMC 2021 | Contributing to open source with the example of icinga (1)
OSMC 2021 | Contributing to open source with the example of icinga (1)NETWAYS
 
We don't need consensus: All agreed?
We don't need consensus: All agreed?We don't need consensus: All agreed?
We don't need consensus: All agreed?Weaveworks
 
Serverless security - how to protect what you don't see?
Serverless security - how to protect what you don't see?Serverless security - how to protect what you don't see?
Serverless security - how to protect what you don't see?Sqreen
 
The 7 deadly sins of micro services
The 7 deadly sins of micro servicesThe 7 deadly sins of micro services
The 7 deadly sins of micro servicesAidan Casey
 
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless SummitBuild a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless SummitCodeOps Technologies LLP
 
Applying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codeApplying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codePuppet
 
Microservice Test Strategy (@Bonn Code Meetup)
Microservice Test Strategy (@Bonn Code Meetup)Microservice Test Strategy (@Bonn Code Meetup)
Microservice Test Strategy (@Bonn Code Meetup)Per Bernhardt
 
Testing Without a GUI Using TestComplete
 Testing Without a GUI Using TestComplete Testing Without a GUI Using TestComplete
Testing Without a GUI Using TestCompleteSmartBear
 
Continuous integration testing 2019 08
Continuous integration testing 2019 08Continuous integration testing 2019 08
Continuous integration testing 2019 08David Stanke
 
Crafting high quality code
Crafting high quality code Crafting high quality code
Crafting high quality code Allan Mangune
 
Forcelandia Salesforce CI
Forcelandia Salesforce CIForcelandia Salesforce CI
Forcelandia Salesforce CIDaniel Hoechst
 
Microservices Testing at Scale
Microservices Testing at ScaleMicroservices Testing at Scale
Microservices Testing at ScaleVMware Tanzu
 

La actualidad más candente (20)

Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data Persistence
 
Production - Designing for Testability
Production - Designing for TestabilityProduction - Designing for Testability
Production - Designing for Testability
 
Thunderstruck by serverless
Thunderstruck  by  serverlessThunderstruck  by  serverless
Thunderstruck by serverless
 
Azure functions
Azure functionsAzure functions
Azure functions
 
CloudFest 2018 Hackathon Project Results Presentation - CFHack18
CloudFest 2018 Hackathon Project Results Presentation - CFHack18CloudFest 2018 Hackathon Project Results Presentation - CFHack18
CloudFest 2018 Hackathon Project Results Presentation - CFHack18
 
When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?
 
Building Autonomous Services
Building Autonomous ServicesBuilding Autonomous Services
Building Autonomous Services
 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
 
OSMC 2021 | Contributing to open source with the example of icinga (1)
OSMC 2021 | Contributing to open source with the example of icinga (1)OSMC 2021 | Contributing to open source with the example of icinga (1)
OSMC 2021 | Contributing to open source with the example of icinga (1)
 
We don't need consensus: All agreed?
We don't need consensus: All agreed?We don't need consensus: All agreed?
We don't need consensus: All agreed?
 
Serverless security - how to protect what you don't see?
Serverless security - how to protect what you don't see?Serverless security - how to protect what you don't see?
Serverless security - how to protect what you don't see?
 
The 7 deadly sins of micro services
The 7 deadly sins of micro servicesThe 7 deadly sins of micro services
The 7 deadly sins of micro services
 
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless SummitBuild a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
Build a Chatbot in Ten Minutes - Dave Kerr - Serverless Summit
 
Applying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance codeApplying Roles and Profiles method to compliance code
Applying Roles and Profiles method to compliance code
 
Microservice Test Strategy (@Bonn Code Meetup)
Microservice Test Strategy (@Bonn Code Meetup)Microservice Test Strategy (@Bonn Code Meetup)
Microservice Test Strategy (@Bonn Code Meetup)
 
Testing Without a GUI Using TestComplete
 Testing Without a GUI Using TestComplete Testing Without a GUI Using TestComplete
Testing Without a GUI Using TestComplete
 
Continuous integration testing 2019 08
Continuous integration testing 2019 08Continuous integration testing 2019 08
Continuous integration testing 2019 08
 
Crafting high quality code
Crafting high quality code Crafting high quality code
Crafting high quality code
 
Forcelandia Salesforce CI
Forcelandia Salesforce CIForcelandia Salesforce CI
Forcelandia Salesforce CI
 
Microservices Testing at Scale
Microservices Testing at ScaleMicroservices Testing at Scale
Microservices Testing at Scale
 

Destacado

20120420 - Design pattern bridge
20120420 - Design pattern bridge20120420 - Design pattern bridge
20120420 - Design pattern bridgeLearningTech
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Patternsahilrk911
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibilityShakil Ahmed
 
Chain of Responsibility Pattern
Chain of Responsibility PatternChain of Responsibility Pattern
Chain of Responsibility PatternHüseyin Ergin
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Patternguy_davis
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design PatternShahriar Hyder
 
Descriptive statistics
Descriptive statisticsDescriptive statistics
Descriptive statisticsRajesh Gunesh
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design PatternAdeel Riaz
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design PatternProdigyView
 
Security and Integrity of Data
Security and Integrity of DataSecurity and Integrity of Data
Security and Integrity of DataAdeel Riaz
 

Destacado (16)

Bridge Pattern Derek Weeks
Bridge Pattern   Derek WeeksBridge Pattern   Derek Weeks
Bridge Pattern Derek Weeks
 
Bridge pattern
Bridge patternBridge pattern
Bridge pattern
 
Bridge Pattern
Bridge PatternBridge Pattern
Bridge Pattern
 
20120420 - Design pattern bridge
20120420 - Design pattern bridge20120420 - Design pattern bridge
20120420 - Design pattern bridge
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Chain of responsibility
Chain of responsibilityChain of responsibility
Chain of responsibility
 
Command Pattern
Command PatternCommand Pattern
Command Pattern
 
Command pattern
Command patternCommand pattern
Command pattern
 
Chain of Responsibility Pattern
Chain of Responsibility PatternChain of Responsibility Pattern
Chain of Responsibility Pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Bridge Design Pattern
Bridge Design PatternBridge Design Pattern
Bridge Design Pattern
 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
 
Descriptive statistics
Descriptive statisticsDescriptive statistics
Descriptive statistics
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Implementing the Adapter Design Pattern
Implementing the Adapter Design PatternImplementing the Adapter Design Pattern
Implementing the Adapter Design Pattern
 
Security and Integrity of Data
Security and Integrity of DataSecurity and Integrity of Data
Security and Integrity of Data
 

Similar a Chain of Responsibility Pattern

Secure Your Open Source Projects For Free
Secure Your Open Source Projects For FreeSecure Your Open Source Projects For Free
Secure Your Open Source Projects For FreeDavide Benvegnù
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Amazon Web Services
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
Introduction to Blockchain and Hyperledger
Introduction to Blockchain and HyperledgerIntroduction to Blockchain and Hyperledger
Introduction to Blockchain and HyperledgerDev_Events
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container securityVolodymyr Shynkar
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?Ksenia Peguero
 
DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2Docker, Inc.
 
Kerberos, Token and Hadoop
Kerberos, Token and HadoopKerberos, Token and Hadoop
Kerberos, Token and HadoopKai Zheng
 
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald BelchamGetting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham.NET Conf UY
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesAmazon Web Services
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsAmazon Web Services
 
Just kill it
Just kill itJust kill it
Just kill itpwhitdog
 
Protect Your Payloads: Modern Keying Techniques
Protect Your Payloads: Modern Keying TechniquesProtect Your Payloads: Modern Keying Techniques
Protect Your Payloads: Modern Keying TechniquesLeo Loobeek
 
Blockchain in the Food Supply Chain (v2)
Blockchain in the Food Supply Chain (v2)Blockchain in the Food Supply Chain (v2)
Blockchain in the Food Supply Chain (v2)Peter Kirchner
 
Application Lifecycle Management
Application Lifecycle ManagementApplication Lifecycle Management
Application Lifecycle ManagementAmazon Web Services
 

Similar a Chain of Responsibility Pattern (20)

Secure Your Open Source Projects For Free
Secure Your Open Source Projects For FreeSecure Your Open Source Projects For Free
Secure Your Open Source Projects For Free
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
Introduction to Blockchain and Hyperledger
Introduction to Blockchain and HyperledgerIntroduction to Blockchain and Hyperledger
Introduction to Blockchain and Hyperledger
 
Securing API data models
Securing API data modelsSecuring API data models
Securing API data models
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
Kubernetes and container security
Kubernetes and container securityKubernetes and container security
Kubernetes and container security
 
How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?How do JavaScript frameworks impact the security of applications?
How do JavaScript frameworks impact the security of applications?
 
DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2DockerCon 15 Keynote - Day 2
DockerCon 15 Keynote - Day 2
 
Kerberos, Token and Hadoop
Kerberos, Token and HadoopKerberos, Token and Hadoop
Kerberos, Token and Hadoop
 
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald BelchamGetting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
Getting Ahead of Delivery Issues with Deep SDLC Analysis by Donald Belcham
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer ToolsDevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
DevOps on AWS: Deep Dive on Continuous Delivery and the AWS Developer Tools
 
SHIFT LEFT WITH DEVSECOPS
SHIFT LEFT WITH DEVSECOPSSHIFT LEFT WITH DEVSECOPS
SHIFT LEFT WITH DEVSECOPS
 
Just kill it
Just kill itJust kill it
Just kill it
 
Protect Your Payloads: Modern Keying Techniques
Protect Your Payloads: Modern Keying TechniquesProtect Your Payloads: Modern Keying Techniques
Protect Your Payloads: Modern Keying Techniques
 
Blockchain in the Food Supply Chain (v2)
Blockchain in the Food Supply Chain (v2)Blockchain in the Food Supply Chain (v2)
Blockchain in the Food Supply Chain (v2)
 
Application Lifecycle Management
Application Lifecycle ManagementApplication Lifecycle Management
Application Lifecycle Management
 

Más de Hélio Costa e Silva

Annotation Sniffer Hotspots implementation
Annotation Sniffer Hotspots implementationAnnotation Sniffer Hotspots implementation
Annotation Sniffer Hotspots implementationHélio Costa e Silva
 
Lightning talk - Framework Architecture: Hotspots
Lightning talk  -  Framework Architecture: HotspotsLightning talk  -  Framework Architecture: Hotspots
Lightning talk - Framework Architecture: HotspotsHélio Costa e Silva
 
Definir classe não é programar com orientação a objetos
Definir classe não é programar com orientação a objetosDefinir classe não é programar com orientação a objetos
Definir classe não é programar com orientação a objetosHélio Costa e Silva
 
WebVibe Barueri 2011 - "PHP por quê ?"
WebVibe Barueri 2011 - "PHP por quê ?"WebVibe Barueri 2011 - "PHP por quê ?"
WebVibe Barueri 2011 - "PHP por quê ?"Hélio Costa e Silva
 
Test-Driven Development - Introdução
Test-Driven Development - IntroduçãoTest-Driven Development - Introdução
Test-Driven Development - IntroduçãoHélio Costa e Silva
 

Más de Hélio Costa e Silva (6)

Annotation Sniffer Hotspots implementation
Annotation Sniffer Hotspots implementationAnnotation Sniffer Hotspots implementation
Annotation Sniffer Hotspots implementation
 
Lightning talk - Framework Architecture: Hotspots
Lightning talk  -  Framework Architecture: HotspotsLightning talk  -  Framework Architecture: Hotspots
Lightning talk - Framework Architecture: Hotspots
 
Vex 2009-2011
Vex 2009-2011Vex 2009-2011
Vex 2009-2011
 
Definir classe não é programar com orientação a objetos
Definir classe não é programar com orientação a objetosDefinir classe não é programar com orientação a objetos
Definir classe não é programar com orientação a objetos
 
WebVibe Barueri 2011 - "PHP por quê ?"
WebVibe Barueri 2011 - "PHP por quê ?"WebVibe Barueri 2011 - "PHP por quê ?"
WebVibe Barueri 2011 - "PHP por quê ?"
 
Test-Driven Development - Introdução
Test-Driven Development - IntroduçãoTest-Driven Development - Introdução
Test-Driven Development - Introdução
 

Último

Radiance Majestic Valasaravakkam Chennai.pdf
Radiance Majestic Valasaravakkam Chennai.pdfRadiance Majestic Valasaravakkam Chennai.pdf
Radiance Majestic Valasaravakkam Chennai.pdfashiyadav24
 
Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|
Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|
Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|AkshayJoshi575980
 
Prestige Somerville Whitefield Bangalore E- Brochure.pdf
Prestige Somerville Whitefield Bangalore E- Brochure.pdfPrestige Somerville Whitefield Bangalore E- Brochure.pdf
Prestige Somerville Whitefield Bangalore E- Brochure.pdffaheemali990101
 
Ajmera Prive at Juhu, Mumbai E-Brochure.pdf
Ajmera Prive at Juhu, Mumbai  E-Brochure.pdfAjmera Prive at Juhu, Mumbai  E-Brochure.pdf
Ajmera Prive at Juhu, Mumbai E-Brochure.pdfManishSaxena95
 
Namrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdf
Namrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdfNamrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdf
Namrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdfPrachiRudram
 
Ebullient Investments Limited specializes in Building contractor
Ebullient Investments Limited specializes in Building contractorEbullient Investments Limited specializes in Building contractor
Ebullient Investments Limited specializes in Building contractorEbullient Investments Limited
 
Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...
Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...
Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...Clemson Engineering Consultant
 
SVN Live 4.22.24 Weekly Property Broadcast
SVN Live 4.22.24 Weekly Property BroadcastSVN Live 4.22.24 Weekly Property Broadcast
SVN Live 4.22.24 Weekly Property BroadcastSVN International Corp.
 
Managed Farmland Brochures to get more in
Managed Farmland Brochures to get more inManaged Farmland Brochures to get more in
Managed Farmland Brochures to get more inknoxdigital1
 
What-are-the-latest-modular-wardrobe-designs.pdf
What-are-the-latest-modular-wardrobe-designs.pdfWhat-are-the-latest-modular-wardrobe-designs.pdf
What-are-the-latest-modular-wardrobe-designs.pdfKams Designer Zone
 
Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...
Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...
Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...AditiAlishetty
 
Dynamic Netsoft A leader In Property management Software
Dynamic Netsoft A leader In Property management SoftwareDynamic Netsoft A leader In Property management Software
Dynamic Netsoft A leader In Property management SoftwareDynamic Netsoft
 
Brigade Neopolis Kokapet, Hyderabad E- Brochure
Brigade Neopolis Kokapet, Hyderabad E- BrochureBrigade Neopolis Kokapet, Hyderabad E- Brochure
Brigade Neopolis Kokapet, Hyderabad E- Brochurefaheemali990101
 
The Role of Mortgage Brokers in Retirement Housing: Key Considerations
The Role of Mortgage Brokers in Retirement Housing: Key ConsiderationsThe Role of Mortgage Brokers in Retirement Housing: Key Considerations
The Role of Mortgage Brokers in Retirement Housing: Key Considerationssunlite Mortgage
 
MADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdf
MADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdfMADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdf
MADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdfknoxdigital1
 
Kumar Fireworks Hadapsar Link Road Pune Brochure.pdf
Kumar Fireworks Hadapsar Link Road Pune Brochure.pdfKumar Fireworks Hadapsar Link Road Pune Brochure.pdf
Kumar Fireworks Hadapsar Link Road Pune Brochure.pdfBabyrudram
 
A Brief History of Intangibles in Ad Valorem Taxation.pdf
A Brief History of Intangibles in Ad Valorem Taxation.pdfA Brief History of Intangibles in Ad Valorem Taxation.pdf
A Brief History of Intangibles in Ad Valorem Taxation.pdfTim Wilmath
 
Everything you ever Wanted to Know about Florida Property Tax Exemptions.pdf
Everything you ever Wanted to Know about Florida Property Tax Exemptions.pdfEverything you ever Wanted to Know about Florida Property Tax Exemptions.pdf
Everything you ever Wanted to Know about Florida Property Tax Exemptions.pdfTim Wilmath
 

Último (20)

Radiance Majestic Valasaravakkam Chennai.pdf
Radiance Majestic Valasaravakkam Chennai.pdfRadiance Majestic Valasaravakkam Chennai.pdf
Radiance Majestic Valasaravakkam Chennai.pdf
 
Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|
Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|
Maha Mauka Squarefeet Brochure |Maha Mauka Squarefeet PDF Brochure|
 
Prestige Somerville Whitefield Bangalore E- Brochure.pdf
Prestige Somerville Whitefield Bangalore E- Brochure.pdfPrestige Somerville Whitefield Bangalore E- Brochure.pdf
Prestige Somerville Whitefield Bangalore E- Brochure.pdf
 
Ajmera Prive at Juhu, Mumbai E-Brochure.pdf
Ajmera Prive at Juhu, Mumbai  E-Brochure.pdfAjmera Prive at Juhu, Mumbai  E-Brochure.pdf
Ajmera Prive at Juhu, Mumbai E-Brochure.pdf
 
Namrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdf
Namrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdfNamrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdf
Namrata 7 Plumeria Drive Pimpri Chinchwad Pune Brochure.pdf
 
Ebullient Investments Limited specializes in Building contractor
Ebullient Investments Limited specializes in Building contractorEbullient Investments Limited specializes in Building contractor
Ebullient Investments Limited specializes in Building contractor
 
Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...
Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...
Clemson Engineering Consultant Dubai For Innovative and Sustainable Engineeri...
 
SVN Live 4.22.24 Weekly Property Broadcast
SVN Live 4.22.24 Weekly Property BroadcastSVN Live 4.22.24 Weekly Property Broadcast
SVN Live 4.22.24 Weekly Property Broadcast
 
Managed Farmland Brochures to get more in
Managed Farmland Brochures to get more inManaged Farmland Brochures to get more in
Managed Farmland Brochures to get more in
 
Hot call girls in Moti Bagh🔝 9953056974 🔝 escort Service
Hot call girls in Moti Bagh🔝 9953056974 🔝 escort ServiceHot call girls in Moti Bagh🔝 9953056974 🔝 escort Service
Hot call girls in Moti Bagh🔝 9953056974 🔝 escort Service
 
What-are-the-latest-modular-wardrobe-designs.pdf
What-are-the-latest-modular-wardrobe-designs.pdfWhat-are-the-latest-modular-wardrobe-designs.pdf
What-are-the-latest-modular-wardrobe-designs.pdf
 
Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...
Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...
Affordable and Quality Construction SVTN's Signature Blend of Cost-Efficiency...
 
young call girls in Lajpat Nagar,🔝 9953056974 🔝 escort Service
young call girls in Lajpat Nagar,🔝 9953056974 🔝 escort Serviceyoung call girls in Lajpat Nagar,🔝 9953056974 🔝 escort Service
young call girls in Lajpat Nagar,🔝 9953056974 🔝 escort Service
 
Dynamic Netsoft A leader In Property management Software
Dynamic Netsoft A leader In Property management SoftwareDynamic Netsoft A leader In Property management Software
Dynamic Netsoft A leader In Property management Software
 
Brigade Neopolis Kokapet, Hyderabad E- Brochure
Brigade Neopolis Kokapet, Hyderabad E- BrochureBrigade Neopolis Kokapet, Hyderabad E- Brochure
Brigade Neopolis Kokapet, Hyderabad E- Brochure
 
The Role of Mortgage Brokers in Retirement Housing: Key Considerations
The Role of Mortgage Brokers in Retirement Housing: Key ConsiderationsThe Role of Mortgage Brokers in Retirement Housing: Key Considerations
The Role of Mortgage Brokers in Retirement Housing: Key Considerations
 
MADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdf
MADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdfMADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdf
MADHUGIRI FARM LAND BROCHURES (11)_compressed (1).pdf
 
Kumar Fireworks Hadapsar Link Road Pune Brochure.pdf
Kumar Fireworks Hadapsar Link Road Pune Brochure.pdfKumar Fireworks Hadapsar Link Road Pune Brochure.pdf
Kumar Fireworks Hadapsar Link Road Pune Brochure.pdf
 
A Brief History of Intangibles in Ad Valorem Taxation.pdf
A Brief History of Intangibles in Ad Valorem Taxation.pdfA Brief History of Intangibles in Ad Valorem Taxation.pdf
A Brief History of Intangibles in Ad Valorem Taxation.pdf
 
Everything you ever Wanted to Know about Florida Property Tax Exemptions.pdf
Everything you ever Wanted to Know about Florida Property Tax Exemptions.pdfEverything you ever Wanted to Know about Florida Property Tax Exemptions.pdf
Everything you ever Wanted to Know about Florida Property Tax Exemptions.pdf
 

Chain of Responsibility Pattern

  • 1. Chain of Responsibility GoF Behavioral Design Pattern
  • 2. Scenario: User Authentication Using email/password Using Local Network Login/pass Authentication Module Using Remote login/pass
  • 4.
  • 5. This mass is available at https://gist.github.com/hlegius/e1a721ebbc7de2a91fb1
  • 6. Code Review • • • • • • • We got a Service class; Skinny Controllers; Meaningful (and cool) names; No temp variable; Short methods; A lot of non-sense `ifs` statements; (Very) Complicated logic. (WTF award!)
  • 7. So, let’s go forward on that ?
  • 8.
  • 9. WTF dude!? Wrong design decision indicator! This mass is available at https://gist.github.com/hlegius/e1a721ebbc7de2a91fb1
  • 10. Chain of Responsibility • Decouple client from receivers when you got more than one object that can handle it; • Giving you the chance to test each part (sender and receivers) in isolated. • Create one point of change if new Receiver arrives. • Added flexibility in assigning responsibilities to objects; • Boost your code readability like a boss.
  • 11. This code is available at https://gist.github.com/hlegius/7188168
  • 12.
  • 13. This code is available at https://gist.github.com/hlegius/7188168
  • 14. This code is available at https://gist.github.com/hlegius/7188168
  • 15. Chain of Responsibility Bad Consequences • More Lines of Code than first version; • Complex if you have one or two fixes receivers; • Receipt is not guaranteed that will be handled;
  • 16. Known Uses • Handle Events – Also known as “Event Handler” or “Responder” • ET++ used Chain of Responsibility to handle Graphical Updates. (Took from GoF book)
  • 17. Macro point of view - UML Client UserAuthenticator Handler Authenticator <abstract> ConcreteHandler1 EmailAuthenticator ConcreteHandler2 NetworkAuthenticator ConcreteHandler3 PartnerAuthenticator
  • 18. Don't get me wrong! You can apply this with PHP, Python, Ruby and so on.