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
IProductACreator |<-- ProductAv1Creator
|<-- ProductAv2Creator
IProductA | <-- ProductAv1
| <-- ProductAv2
You can keep the IProductACreator and change its implementation to get ProductA of different versions
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
Ensure a class only has one instance
Separate the parts and their assemble algorithms to build different final products
Structural
An alternative to inheritance
An application of Composition, two can vary independently
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
IObject | <-- WorkingObject
| <-- ProxyObject
ProxyObject do nothing but redirect the request, it depends on WorkingObject
The same as the adapter in STL
Behavioral
Nothing but virtual function overrided
Chain the receiving objects and pass the request along the chain until an object handles it
Just like the functor in STL, but STL uses template and the command Pattern uses virtual function
Just like the iterator in STL
Nothing but the mechanism used in Flex Event System
Strategy lets the algorithm vary independently from clients that use it
面象对象的封装特性将数据和方法绑定, 然而“绑定”这两个字就和“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