Home > Patterns and Practices > Chain of Responsibility Pattern

Chain of Responsibility Pattern

Chain of Responsibility

Problem:

How do you decouple a request’s sender and receiver, multiple objects, determined at runtime, are candidates to handle a request. Also you don’t want to specify handlers explicitly in your code.

 

Solution:

The Chain of Responsibility pattern comes to the rescue. The GoF class structure diagram and the object structure are shown below.

Examples of CoR:

The exception bubbling architecture in .NET, the Windows messages which bubble up the hierarchy till they are handled. The classic CoR has the following characteristics:

·          Only one object in the chain handles a request

·          Some requests might not get handled

But then a slighter variation of this could be where each object in the handles the request and passes it further up the chain for processing. This specific variation of CoR is typically called the “Intercepting Filter” pattern. The Remoting sink chain architecture is a typical example of this variation of CoR.

 

Some also say that Intercepting Filter is a CoR variation with a controller and in which all the handlers are executed sequentially.

Advertisements
  1. No comments yet.
  1. November 19, 2010 at 11:00 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: