Category: 

What Is a Chain of Responsibility?

Article Details
  • Written By: C. Daw
  • Edited By: O. Wallace
  • Last Modified Date: 15 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
Due to synthetic materials and furnishings, new homes burn about five times faster than those built 30 years ago.  more...

September 25 ,  1789 :  The US Bill of Rights was adopted.  more...

The chain of responsibility (CoR) involves the process of indicating the activities and responsibilities of each and every entity in the object oriented design pattern. There are two basic elements in an object oriented design; command objects and processing objects. The command objects generate the commands to the processing objects and the processing objects choose from the commands that they can handle and pass the rest to the others in the chain. This is the basic principle in object oriented design, and there is a lot more flexibility in the design, such as the new enclosure of the objects at any location in the design pattern of the chain of responsibility.

The advantage behind the object oriented design is that communication is not limited to the sender and the receiver because there are many objects there to handle the sender's command. There is a chain of different objects that line up to handle the commands, and if one cannot handle it then it can pass it on to the next one in the chain. The chain of responsibility continues to go on until one of the objects accepts the command.

Ad

The chain of responsibility needs to be more flexible and support the addition of new handlers in the chain. Since each handler is not able to do each and every task, there must be a group of the handlers that can work collectively. There could be some drawbacks to the chain of responsibility as some of the commands remain unsolved, even at the end of the chain. To address this issue, one solution is to implement all the handlers for all the possible requests.

There could be some problems related to the broken links in the chain of responsibility system. If the programmer forgets to link the commands then the request could get lost. The request representation is significant because it is being used in all of the components of the chain of responsibility. Another flaw that could be in the design of the CoR is that due to some problems in the concrete handler, some requests may end up totally unaddressed at the end of the chain. But all in all, the chain of responsibility is a good system to implement if it has carefully been designed, considering all of the related aspects.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

Post Anonymously

Login

username
password
forgot password?

Register

username
password
confirm
email