Chain of Responsibility | Decorator |
---|---|
Comparable to "pipe and filter" (an object-oriented linked list) | Comparable to layered architecture (layers of an onion) |
The "filter" objects are peers (equal rank) | A "core" object is assumed, all "layer" objects are optional |
2 levels in inheritance hierarchy: base class, filter classes | 3 levels in inheritance hierarchy: top-level "lowest common denominator" (LCD) interface, mid-level core class and decorator class, bottom-level layer classes |
Filter objects delegate to the base class, and the base class delegates to the "next" filter object | Layer objects delegate to the decorator class, and the decorator class delegates to the next LCD object |
User views the chain as a "launch and leave" pipeline | User views the decorated object as an enhanced object |
A request is routinely forwarded until a single filter object handles it. But, many (or all) filter objects could contribute to each request's handling. | A layer object always performs pre or post processing as the request is delegated. |
All the handlers are peers (like nodes in a linked list) - "end of list" condition handling is required. | All the layer objects ultimately delegate to a single core object - "end of list" condition handling is not required. |