桥接模式(Bridge)
桥接模式用于解决系统多维度变化的问题,将抽象部分与实现部分分离,使它们都可以独立的变化。(参见对Bridge模式的理解 )
结构图:
生活中的例子:
组合模式(Composite)
意图:
将对象组合成树形结构以表示“部分-整体”的层次结构。Composite模式使得用户对单个对象和组合对象的使用具有一致性。[GOF 《设计模式》]
生活中的例子:
组合模式最佳例子是.NET的控件树,具体参考张逸的《设计之道》,或看.NET控件源码。
结构图:
享原模式(FlyWeight)
当在一个线程中需要创建一个类的很多实例,而这个类的实例之间只是某些状态不同,就可以考虑是否可以将类中实例化后不同的部分提取出来,以使剩余的部分得以共享,减少内存开销。这种解决方法就是享原模式,它主要是解决上面提到的性能问题。
结构图:
代理模式(Proxy)
结构图:
代码:























































