设计模式学习笔记
最近利用早晨的大好时光,学习了一下设计模式,同时学习了英语。目前一共学习了八种模式:
一、 The Observer Pattern
It defines a one to many relationship between a set of objects. When the state of one object changes, all of its dependents are notified.
二、 The Decorator Pattern
It attaches additional responsibilities to an object dynamically.Decorators provide a flexible alternative to subclassing for extending functionality.
三、 The Factory Pattern
It defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclass.
四、 The Abstract Pattern
It provides an interface for creating families of related or dependent objects without specifying their concrete classes.
五、 The Singleton Pattern
It ensures a class has only one instance, and provides a global point of access to it.
六、 The Command Pattern
It encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.
七、 The Adapter Pattern
It converts the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn’t otherwise because of imcompatible interface.
八、 The Façade Pattern
It provides a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.
在这上述的八个模式中,包含了设计模式的三种类型:创建型模式,结构型模式,行为模式。其中Factory、Abstract Factory、Singleton为创建型模式,Decorator、Adapter、Facade为结构型模式,其余的Command和Observer为行为模式。
不过,感觉有时侯理解的特别清楚,但过一段时间就忘了。所以一定要将其用起来,才能对其有深深的体会,不会就是死的知识。一定要让其活起来。
呵呵,又看了一些蜗牛的家写的设计模式趣解,反而更有助于理解呦,不妨看看。链接地址为:http://www.cppblog.com/bangle/archive/2008/08/23/59725.html
posted on 2009-07-21 18:11
Sandy 阅读(369)
评论(0) 编辑 收藏 引用 所属分类:
设计模式