1 00:00:01,450 --> 00:00:07,630 The chain of responsibility pattern is characterized by a chain of receiver objects, each object dealing 2 00:00:07,630 --> 00:00:09,850 with a certain aspect of your application. 3 00:00:11,130 --> 00:00:17,040 A slender object sends a request to an interface, and then the request is passed through the chain 4 00:00:17,040 --> 00:00:19,310 to check the different aspects of it. 5 00:00:20,790 --> 00:00:23,160 The urinal diagram shows exactly that. 6 00:00:24,160 --> 00:00:31,090 We have a handler interface which defines a contract for the concrete handlers, the concrete handlers 7 00:00:31,330 --> 00:00:34,800 will pass the request to each other up in the chain hierarchy. 8 00:00:35,680 --> 00:00:40,140 A typical usage of this would be in a logging component of an application. 9 00:00:41,260 --> 00:00:46,690 You would typically have two classes that deal with authentication and authorization, both of them 10 00:00:46,690 --> 00:00:49,940 being in the same chain generally. 11 00:00:50,440 --> 00:00:56,280 You use this pattern when you want to perform sequential tasks before reaching a final object. 12 00:00:57,870 --> 00:01:03,840 Also, when there needs to be multiple levels of escalation for different handlers, an example would 13 00:01:03,840 --> 00:01:08,640 be a payment processor where you need different types of approvals for different payments that need 14 00:01:08,640 --> 00:01:09,330 to be approved. 15 00:01:10,750 --> 00:01:13,760 Let's have a look at the implementation of this pattern in the current.