Strategy Pattern V/S Decorator Pattern

后端 未结 7 1314
星月不相逢
星月不相逢 2021-01-29 20:06

I just came across two patterns.

  1. Strategy Pattern

  2. Decorator

Strategy Pattern :-

Strategy pattern

7条回答
  •  悲&欢浪女
    2021-01-29 20:52

    Decorator is to add extra functionality to an instance of a class, so it is implemented in runtime dynamically.It is a pattern of behavior extensions. Due to the practical conditions under which Subclassing is back breaking. Strategy is a pattern which different Strategy objects share the same abstract function, the concrete context object can be configured at run time with the concrete strategy object of a family set. As MVC, controller is a case of strategy role, the view restrain the output data structure, while-as the controllers will be different at runtime, which dynamically change the output data of view.

提交回复
热议问题