1.singleton 模式
类只有一个实例,并且为之提供一个全局的访问点。
例子:Ext.util.JSON This class is a singleton and cannot be created directly.
2.observer 模式
多个对象之间定义一对多的关系,以便当一个对象状态改变的时候,其他所有依赖于这个对象的对象都能够得到通知,并被自动更新。
例子:Ext.util.Observable Abstract base class that provides a common interface for publishing events. Subclasses are expected to to have a property "events" with all the events defined.
以及所有实现了这个接口的类
3.mediator 模式
定义一个对象,该对象将对象之间的交互封装起来。利用该模式可以降低对象之间的耦合程度,避免对象之间的显示引用,还可以让对象之间的交互独立变化。
例子:Ext.grid.RowSelectionModel The default SelectionModel used by Ext.grid.GridPanel. It supports multiple selections and keyboard selection/navigation. The objects stored as selections and returned by getSelected, and getSelections are the Records which provide the data for the selected rows.
4.proxy 模式
为对象提供一个代理来控制对该对象的访问。
例子:Ext.data.DataProxy This class is an abstract base class for implementations which provide retrieval of unformatted data objects ,提供对数据的不同访问方式。
5.责任链模式
让每个对象都有机会决定自己是否处理请求,以便于避免请求的发送者与其接受者的耦合。
例子:Ext.Component 及其子类 ,子类可以改写 initComponet 如果自己想参与初始化,否则就有父类处理。
091030:(最好应该算作 template 模式 ,好莱坞模式,不用找我等我来找你) initComponent 由框架组件调用
6.flyweight pattern
通过共享来支持大量的细粒度对象的使用效率。
例子: Ext.fly 方法 ,共享 element