Chinaunix首页 | 论坛 | 博客
  • 博客访问: 257852
  • 博文数量: 60
  • 博客积分: 1222
  • 博客等级: 少尉
  • 技术积分: 585
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-16 17:28
个人简介

从学通信的博士到从事IT行业的工程师 从原华为项目经理,到现任职公司架构师

文章分类

全部博文(60)

文章存档

2013年(18)

2012年(42)

我的朋友

分类: C/C++

2012-12-23 20:23:15

The decorator has same interfaces to component to which it enhances functions or appearance. It is also called wrapper. With this pattern, client does not need to subclass or change components it uses.
The decorator owns reference to component it decorates. The client references one component which may be a decorator or a component. The client does know who the component is because both are subclasses inherited from one common abstract class.

facade is one kind of pattern which extracts simple interfaces from complicated classes whose details the client is not interested. Certainly the may also use those complex classes which the facade extracts simple classes from.

Singleton is a special class which has exactly one instance. It can be subclasses.

Flyweight uses sharing to support large number of fine-grained objects effectively.
Intrinsic state is stored in flyweight because it is independent of the flyweight's context, thereby making it shareable. Clients are responsible for passing extrinsic state to flyweight object.
Clients maintain a reference to flyweight object, which is created by a flyweight factory to guaranty shareable, and compute, store extrinsic state for flyweight object.
Flyweights may introduce run-time costs.

Adapter is used to realize converting the interface of one class to another interface client expects. By this, existing class can be reused to new application with incompatible interface.
There are two approaches corresponding to class and object versions of adapter pattern.
I remember that I have ever created one stack class based on c++ vector template class although it is not efficient.
Compared with decorator pattern with unchanged interface, compatible interface will be built to support new requirement.
阅读(827) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~