装饰者模式:
     动态的将责任附加到对象上。想要扩展功能,装饰者提供了有别于继承的另外一种选择。
 
设计原则:
5、对扩展开放,对修改关闭。
 
示例类图
以《Head First Design Patterns》中的咖啡为例。
装饰者模式 The Decorator Pattern
 
有双摩卡、豆浆、奶泡的House Blend咖啡,价格计算:
装饰者模式 The Decorator Pattern
 
 
Java JDK中的装饰者模式:
装饰者模式 The Decorator Pattern
 
(转载请注明出处 ^.^)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-10-12
猜你喜欢
  • 2021-08-03
  • 2021-09-06
  • 2021-05-02
  • 2021-05-16
  • 2021-11-16
  • 2021-06-27
相关资源
相似解决方案