【发布时间】:2014-12-12 21:51:56
【问题描述】:
我刚刚遇到了两种模式。
策略模式
装饰器
策略模式:-
策略模式提供了几种可用于执行的算法 特定的操作或任务。
装饰器模式:-
装饰器模式为组件添加了一些功能。
其实我发现Strategy Pattern 和 Decorator Pattern 也可以互换使用。
这是链接:- When and How Strategy pattern can be applied instead of decorator pattern?
策略模式和装饰器模式有什么区别?
什么时候应该使用策略模式,什么时候应该使用装饰器模式?
用同一个例子解释两者之间的区别。
【问题讨论】:
标签: design-patterns decorator strategy-pattern