decorate -- 通过反复包含对像,并对已包含对象方法添加功能
2009-08-14 16:23
260 查看
Function:
The decorator pattern can be used to make it possible to extend (decorate) the functionality of a class at runtime.
Actors:
FunctionInterface, BasicFunctionClass, decorator, concreteDecorator
Summary
FunctionInterface is to define decoratable method.
BasicFunctionClass defines the basic functionality.
Decorator is the core of this design pattern, is has a FunctionInterface property.
All ConcreteDecorators will overrite the method and patch new functionality to the overriden class.
The decorator pattern can be used to make it possible to extend (decorate) the functionality of a class at runtime.
Actors:
FunctionInterface, BasicFunctionClass, decorator, concreteDecorator
Summary
FunctionInterface is to define decoratable method.
BasicFunctionClass defines the basic functionality.
Decorator is the core of this design pattern, is has a FunctionInterface property.
All ConcreteDecorators will overrite the method and patch new functionality to the overriden class.
相关文章推荐
- main函数中通过使用Person类和AddressBook类,创建对象、调用方法,实现以下8个功能
- 通过代理为对象添加功能
- Spring中c3p0连接池的配置 及JdbcTemplate的使用 通过XML配置文件注入各种需要对象的操作 来完成数据库添加Add()方法
- 自定义绘图添加抗锯齿功能 尽量不要在onDraw()方法中创建paint对象
- JavaScript通过function定义对象并给对象添加toString()方法实例分析
- 针对PDF文件无法添加注释、附注、书签等功能的解决方法(已测试通过)
- 地磅称量系统之(53)在封装对象的类库中实现包括IDataErrorInfo接口提供的所有方法和并且扩展对异常具有添加和删除功能的基本业务对象基类
- 继承与合成基本概念 继承:可以基于已经存在的类构造一个新类。继承已经存在的类就可以复用这些类的方法和域。在此基础上,可以添加新的方法和域,从而扩充了类的功能。 合成:在新类里创建原有的对象称为合成。
- 通过Spring Aop编程思想,利用注解为某些对象添加新的功能
- 类继承接口, 通过接口对象new继承类的类(包含派生类),调用对象方法,其实其第一个接口继承的
- 使用扩展方法和接口给对象添加“重置状态”功能
- C#用扩展方法进行自动生成添加删除对象转换的功能
- QTP在录制脚本的时候会将鼠标点击过的对象自动添加到对象库中,而那些未被点击过的对象将不会被添加,导致针对某一对象手动添加的脚本运行不通过,因此需要手动把测试对象添加到对象库中,方法如下:
- 通过 prototype 为 JavaScript 的 String 对象添加方法(函数)
- ios开发-UISlider通过滑动添加单元格功能
- 统一的为对象添加多播事件委托的方法
- js中为一个对象添加事件的正确方法
- 模拟实现MyBites中通过SQL反射实体类对象功能
- 修改ecshop添加通过快递单号搜索订单的功能
- (44)通过继承创建线程对象的例子+getName+setName+currentThread()方法应用介绍