== UML Diagram ==
**If it can handle the request it does so, otherwise it sends the request to its successor
* '''Client''' - sends commands to the first object in the chain that may handle the command
Here are a few situations when using the Chain of Responsibility is more effective:
* More than one object can handle a request
* The handler is not known in advance
* The handler should be determined automatically
* It’s wished that the request is addressed to a group of objects without explicitly specifying its receiver
* The group of objects that may handle the request must be specified in a dynamic way
== Drawbacks ==
* '''Unhandled requests'''
**Unfortunately, the Chain doesn't guarantee that every command is handled, which makes the problem worse, since unhandled commands propagate through the full length of the chain, slowing down the application. One way to solve this is by checking if, at the end of the chain, the request has been handled at least once, otherwise we will have to implement handlers for all the possible requests that may appear.
*''' Broken Chain''' **Sometimes we could forget to include in the implementation of the handleRequest method the call to the successor, causing a break in the chain . The request isn’t sent forward from the broken link and so it ends up unhandled.
== Code Examples ==
==== Java Example ===
== = =
C # Example = = =
External Links == *External Links
15: 49, 2 April 2007 (EDT)