GoF Pattern

 

Creational

* Factory Method      

* Abstract Factory

 

 

* Singleton

 

* Builder

 

 

 

Structural

 

* Composite

 

* Bridge

* Decorator

* Proxy

* Adapter

Behavioral

 

* Template Method

* Chain of Responsibility

* Command

* Iterator

* Observer

* Strategy

 

 

* Visitor

 

 

 

 

 

 

 

Creational


* Factory Method

 

   IProductACreator  |<-- ProductAv1Creator

                                |<-- ProductAv2Creator

 

   IProductA | <-- ProductAv1

                   | <-- ProductAv2

 

   You can keep the IProductACreator and change its implementation to get ProductA of different versions

 

 

 


* Abstract Factory

 

   Provide an interface for creating families of related or dependent objects:

 

   IFactory  |  <-- Factory for A family products

                  |  <-- Factory for B family products

                  |  <-- Factory for C family products

  

  And A, B, C family products share the same collection of product interfaces

 

 


* Singleton

 

   Ensure a class only has one instance

 

 


* Builder

  

   Separate the parts and their assemble algorithms to build different final products

 

 

Structural

 

 


* Composite

  

   An alternative to inheritance

 

 


* Bridge

 

   An application of Composition, two can vary independently

 

 


* Decorator

 

   An application of Composition, It's a good example of reusing existing object

 

   IObject | <-- ExistingObject

                | <-- DecoratedObject

 

   Note: DecoratedObject depends on ExistingObject, though they have a same interface

 

 


* Proxy

 

   IObject | <-- WorkingObject

                | <-- ProxyObject

 

   ProxyObject do nothing but redirect the request, it depends on WorkingObject

 

 


* Adapter

   The same as the adapter in STL

 

 

 

Behavioral

 


* Template Method

  

   Nothing but virtual function overrided

 


* Chain of Responsibility

   

     Chain  the  receiving  objects and pass the request along the chain until an object handles it

 


* Command

   Just like the functor in STL, but STL uses template and the command Pattern uses virtual function

 


* Iterator

   Just like the iterator in STL

 

 


* Observer

   Nothing but the mechanism used in Flex Event System

 


* Strategy

   Strategy  lets  the  algorithm  vary  independently  from clients that use it

 


* Visitor

 

   面象对象的封装特性将数据和方法绑定, 然而“绑定”这两个字就和“Flexible”相冲突了

   假设一下你的数据和方法不死绑定,假设一下一个类的方法集是可变的

   Now,Here comes the Visitor, every visitor is a different method suit

   Application Sinaro: A collection of different objects(the data), you can use different vistor to visit these objects

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值