Why would I ever use a Chain of Responsibility over a Decorator?

后端 未结 11 1909
[愿得一人]
[愿得一人] 2020-12-04 12:58

I\'m just reading up on the Chain of Responsibility pattern and I\'m having trouble imagining a scenario when I would prefer its use over that of decorator.

What do

11条回答
  •  既然无缘
    2020-12-04 13:32

    Decorator is used when you want to add functionality to an object.

    COR is used when one of many actors might take action on an object.

    A particular Decorator is called to take an action, based on the type; while COR passes the object along a defined chain until one of the actors decides the action is complete.

    COR might be used when there are multiple levels of escalation to different handlers -- for instance, a call center where the customer's value to the company determines if the call goes to a particular level of support.

提交回复
热议问题