Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fb7898f

Browse files
author
deeper
committed
add decorator
1 parent 65fd2fc commit fb7898f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.ruoxu.pattern.decorator;
2+
/**
3+
* 装饰器模式(结构型设计模式)
4+
* 动态地扩展类的功能。装饰器模式相对于生成子类更灵活,可以替代子类继承或实现接口的方式来扩展类的功能。
5+
* 易混淆点:
6+
* 装饰器模式与代理模式很像,有时候甚至混淆,常常会是把装饰器模式看作是代理模式。
7+
* 1.装饰器模式是以 对客户端透明的方式扩展对象的功能,是继承关系的一个替代方法。
8+
* 2.代理模式则是给一个对象提供一个代理对象,并由代理对象来控制对原有对象的引用。装饰器模式应该为所装饰的对象增强功能;代理模式对代理对象施加控制,但不对对象本身的功能进行增强。
9+
*
10+
*/
11+
public class Demo {
12+
public static void main(String[] args) {
13+
14+
}
15+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /