ITeye博客

JAVA设计模式学习笔记–装饰者模式

rommal7090 · 2010-03-26 22:59 · java · 企业架构 · Markdown

装饰者模式:

1. 装饰者模式动态的将责任附加到对象上,若要扩展功能,装饰者模式比继承提供了更有弹性的替代方案。

2.装饰者模式在JDK中的代表

java.io包:

InputStream---抽象组件

FileInputStream, StringBufferInputStream,ByteArrayInputStream.FilterInputStream---这些类继承于 InputStream类,是可以被装饰者包起来的具体组件,其中FilterInputStream是一个抽象装饰者。

PushBackInputStream,BufferedInputStream,DataInputStream---具体的装饰者,装饰 FilterInputStream

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。