| Table of Contents | |
| Structure | |
|
Figure 3 - Typical Structure of a Chain of Responsibility |
|
| Collaborations | |
| The collaborations in a Chain of
Responsibility design pattern are obvious. The request propogates along
the chain
until a handler object takes responsibility for
handling it. |
|
| Implementation Issues | |
|
Successor Chain |
According to Gamma et al (1994), there are two ways of implementing the successor chain Definition of new links or use of existing links.
|
|
Connecting successors
|
If no existing references exist then the links will need to be defined. If this is the case then the top-level Handler can maintain the successor as well as define the interface. The Handler then provides the default method to forward requests on to the successor. This allows the ConcreteHandler subclasses to basically ignore the interface method unless it wishes to override the method. |
|
C++ Example (Gamma et al, 1994, p.227) |
class helpHandler { public :
private:
}; void HelpHandler::HandleHelp () {
} |
|
Representing requests
|
Can use a Request class to bundle request parameters.(Command Pattern related?) |
| Known uses | |
|
User Events  |
MacApp, ET+ (Event Hander) Symantec TCL (Bureaucrat) NeXT AppKit (Responder) |
|
Graphics |
Unidraw ET++ |
| Related patterns | |
|
|
|
| Disscussion Items/Questions | |
|
|
| References | |
| Gamma, E., Helm, R., Johnson, R. & Vlissides, J. (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Reading Mass., Addison Wesley. | |
| Pree, W. (1995). Design Patterns for Object-Oriented Software Development. Reading Mass, Addison-Wesley. |