The Decorator Pattern 装饰者模式
来源:互联网 发布:笔记本电脑如何优化 编辑:程序博客网 时间:2024/05/29 14:31
本模式可以称为“给爱用继承的人一个全新的设计眼界”。利用对象组合的方式,做到在运行时装饰类,使得能够在不修改任何底层代码的情况下,给对象赋上新的职责。
装饰者模式:动态的将责任附加到对象上。若要扩展功能,装饰者提供了比继承更有弹性的替代方案。
来看看类图:
- 装饰者和被装饰者有相同的超类型,因此可以在任何需要原始对象的场合,可以用装饰过的对象替代它。
- 可以有一个或者多个装饰者包装一个对象。
- 装饰者可以在所委托被装饰者的行为之前或者之后,加上自己的行为,以达到特定的目的。
- 对象可以在任何时候被装饰,所以可以在运行时动态的,不限量地用你喜欢的装饰者来装饰对象。
来试试用这个栗子来给星巴克设计订单系统吧
Java.io包中的装饰者模式:
0 0
- 装饰者模式(the Decorator Pattern)
- 装饰者模式 The Decorator Pattern
- The Decorator Pattern 装饰者模式
- Decorator Pattern (装饰者模式)
- 装饰者模式(Decorator Pattern)
- 装饰者模式(decorator pattern)
- 装饰者模式(Decorator Pattern)
- 装饰者模式(Decorator Pattern)
- Decorator Pattern 装饰者模式
- 装饰者模式(Decorator Pattern)
- 装饰者模式 Decorator Pattern
- Decorator Pattern(装饰者模式)
- 装饰者模式-Decorator Pattern
- 装饰者模式 | Decorator Pattern
- 装饰模式Decorator Pattern
- 装饰模式(Decorator Pattern)
- 装饰模式(Decorator Pattern)
- 装饰模式--Decorator pattern
- ios框架学习
- 一个女大学生的代码学习之路(一)
- 黑马程序员-代理
- matplotlib 安装
- 使用axis1+spring+hibernate搭建webservice框架
- The Decorator Pattern 装饰者模式
- 使用TeaJs制作Rpg游戏-无耻发布
- 谨慎使用STL中的erase操作!
- 设计模式学习总结(18) 命令模式
- IOS 解决键盘挡住输入框的问题
- 在Windows下编译FFmpeg详细说明
- IOS学习笔记36—解决键盘遮挡输入框(UITextField)问题
- 浅析企业该怎么做事件营销
- Android AES算法示例