Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Python Design Patterns

You're reading from   Mastering Python Design Patterns A guide to creating smart, efficient, and reusable software

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher
ISBN-13 9781788837484
Length 248 pages
Edition 2nd Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Sakis Kasampalis Sakis Kasampalis
Author Profile Icon Sakis Kasampalis
Sakis Kasampalis
Kamon Ayeva Kamon Ayeva
Author Profile Icon Kamon Ayeva
Kamon Ayeva
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. The Factory Pattern FREE CHAPTER 2. The Builder Pattern 3. Other Creational Patterns 4. The Adapter Pattern 5. The Decorator Pattern 6. The Bridge Pattern 7. The Facade Pattern 8. Other Structural Patterns 9. The Chain of Responsibility Pattern 10. The Command Pattern 11. The Observer Pattern 12. The State Pattern 13. Other Behavioral Patterns 14. The Observer Pattern in Reactive Programming 15. Microservices and Patterns for the Cloud 16. Other Books You May Enjoy

Use cases

By using the Chain of Responsibility pattern, we provide a chance to a number of different objects to satisfy a specific request. This is useful when we don’t know which object should satisfy a request in advance. An example is a purchase system. In purchase systems, there are many approval authorities. One approval authority might be able to approve orders up to a certain value, let's say $100. If the order is for more than $100, the order is sent to the next approval authority in the chain that can approve orders up to $200, and so forth.

Another case where the Chain of Responsibility is useful is when we know that more than one object might need to process a single request. This is what happens in event-based programming. A single event, such as a left-mouse click, can be caught by more than one listener.

It is important to note that the Chain of Responsibility...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image