skip to Main Content

Welcome

Say hello to the toggle bar. This is an optional section you can use to display any content you'd like. Simply select a page from the theme panel and the content of the page will display here. You can even use the drag and drop builder to create this! This is a perfect place for your company mission statement, alerts, notices or anything else.

Get In Touch

Email: support@total.com
Phone: 1-800-Total-Theme
Address: Las Vegas, Nevada

Our Location

togglebar-map

Chain of Responsibility Pattern

Post Series: Behavioral Design Pattern

The chain of responsibility pattern is used to process a list or chain of various types of request and each of them may be handle by a different handler. This pattern decouples sender and receiver of a request based on type of request.

In this pattern, normally each receiver (handler) contains reference to another receiver. If one receiver cannot handle the request then it passes the same to the next receiver and so on.

 

Client: This is the class that generates the request and passes it to the first handler in the chain of responsibility.
Handler: This is the abstract class that contains a member that holds the next handler in the chain and an associated method to set this successor. It also has an abstract method that must be implemented by concrete classes to handle the request or pass it to the next object in the pipeline.
ConcreteHandlerA & ConcreteHandlerB: These are concrete handlers classes inherited from Handler class. These include the functionality to handle some requests and pass others to the next item in the chain of request.

 

Implement

Example

 

Resource

http://www.dotnettricks.com/learn/designpatterns/chain-of-responsibility-design-pattern-dotnet

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top