創(chuàng)建模式(Creational Pattern):AbstractFactory Builder FactoryMethod Prototype Singleton
結(jié)構(gòu)模式(Structural Pattern):Adapter.4Class adapter.4Object Bridge Composite.s Composite.t Decorator Facade Flyweight Proxy
行為模式(Behavioral Pattern):ChainOfResponsibility Command Interpreter Iterator Mediator Memento Observer Strategy State TemplateMethod Visitor
下載所有示例代碼和文檔 From www.niufish.com.
See:
Description
Packages | |
com.niufish.pattern.abstractFactory | 抽象工廠(Abstract Factory)模式![]() 意圖:為特定的客戶(或情況)提供特定系列的對象。 |
com.niufish.pattern.adapter.forClass | 類的適配器(Adapter)模式![]() 意圖:將一個類的接口轉(zhuǎn)換成客戶希望的另外一個接口。 |
com.niufish.pattern.adapter.forObject | 對象的適配器(Adapter)模式![]() 意圖:將一個類的接口轉(zhuǎn)換成客戶希望的另外一個接口。 |
com.niufish.pattern.bridge | 橋梁(Bridge)/柄體(Handle and Body)模式![]() 意圖:將抽象部分與它的實現(xiàn)部分分離,使它們都可以獨(dú)立地變化。 |
com.niufish.pattern.builder | 建造(Builder)模式![]() 意圖:將一個復(fù)雜對象的構(gòu)建與它的表示分離,使得同樣的構(gòu)建過程可以創(chuàng)建不同的表示。 |
com.niufish.pattern.chainOfResponsibility | 責(zé)任鏈(Chain of Responsibility)模式![]() 意圖:使多個對象都有機(jī)會處理請求,從而避免請求的發(fā)送者和接收者之間的耦合關(guān)系。 |
com.niufish.pattern.command | 命令(Command)模式(感覺圖不是很精確)![]() 意圖:將一個請求封裝為一個對象,從而使你可用不同的請求對客戶進(jìn)行參數(shù)化;對請求排隊或記錄請求日志,以及支持可撤消的操作。 |
com.niufish.pattern.composite.safe | 合成(Composite)/整體(Part-Whole)模式 [安全式]![]() 意圖:將對象組合成樹形結(jié)構(gòu)以表示“部分-整體”的層次結(jié)構(gòu)。 |
com.niufish.pattern.composite.transparence | 合成(Composite)/整體(Part-Whole)模式 [透明式] 同[安全式]圖 意圖:將對象組合成樹形結(jié)構(gòu)以表示“部分-整體”的層次結(jié)構(gòu)。 |
com.niufish.pattern.decorator | 裝飾器(Decorator)模式![]() 意圖:動態(tài)地給一個對象添加一些額外的職責(zé)。 |
com.niufish.pattern.facade | 門面(Facade![]() ![]() 意圖:為子系統(tǒng)中的一組接口提供一個一致的界面,此模式定義了一個高層接口,這個接口使得這一子系統(tǒng)更加容易使用。 |
com.niufish.pattern.factoryMethod | 工廠方法(Factory Method)/虛擬構(gòu)造子(virtual Constructor)/多態(tài)性工廠(Polymorphic Factory)模式![]() 意圖:定義一個用于創(chuàng)建對象的接口,讓子類決定實例化哪一個類。 |
com.niufish.pattern.flyweight | 享元(Flyweight)模式![]() 意圖:運(yùn)用共享技術(shù)有效地支持大量細(xì)粒度的對象。 |
com.niufish.pattern.interpreter | 解釋器(Interpreter)模式![]() 意圖:給定一個語言,定義它的文法的一種表示,并定義一個解釋器,這個解釋器使用該表示來解釋語言中的句子。 |
com.niufish.pattern.iterator | 迭代子(Iterator)/游標(biāo)(Cursor)模式![]() 意圖:提供一種方法順序訪問一個聚合對象中各個元素, 而又不需暴露該對象的內(nèi)部表示。 |
com.niufish.pattern.mediator | 調(diào)停者(Mediator)模式![]() 意圖:用一個中介對象來封裝一系列的對象交互。 |
com.niufish.pattern.memento | 備忘錄(Memento)模式![]() 意圖:在不破壞封裝性的前提下,捕獲一個對象的內(nèi)部狀態(tài),并在該對象之外保存這個狀態(tài)。 |
com.niufish.pattern.observer | 觀察者(Observer)模式![]() 意圖:定義對象間的一種一對多的依賴關(guān)系,當(dāng)一個對象的狀態(tài)發(fā)生改變時, 所有依賴于它的對象都得到通知并被自動更新。 |
com.niufish.pattern.prototype | 原型(Prototype)模式![]() 意圖:用原型實例指定創(chuàng)建對象的種類,并且通過拷貝這些原型創(chuàng)建新的對象。 |
com.niufish.pattern.proxy | 代理(Proxy)模式![]() 意圖:為其他對象提供一種代理以控制對這個對象的訪問。 |
com.niufish.pattern.singleton | 單例(Singleton)模式![]() 意圖:保證一個類僅有一個實例,并提供一個訪問它的全局訪問點。 |
com.niufish.pattern.state | 狀態(tài)(State)模式![]() 意圖:允許一個對象在其內(nèi)部狀態(tài)改變時改變它的行為。 |
com.niufish.pattern.strategy | 策略(Strategy)模式![]() 意圖:定義一系列的算法,把它們一個個封裝起來, 并且使它們可相互替換。 |
com.niufish.pattern.templateMethod | 模版方法(Template Method)模式![]() 意圖:定義一個操作中的算法的骨架,而將一些步驟延遲到子類中。 |
com.niufish.pattern.visitor | 訪問者(Visitor)模式![]() 意圖:表示一個作用于某對象結(jié)構(gòu)中的各元素的操作。 |
創(chuàng)建模式(Creational Pattern):AbstractFactory Builder FactoryMethod Prototype Singleton
結(jié)構(gòu)模式(Structural Pattern):Adapter.4Class adapter.4Object Bridge Composite.s Composite.t Decorator Facade Flyweight Proxy
行為模式(Behavioral Pattern):ChainOfResponsibility Command Interpreter Iterator Mediator Memento Observer Strategy State TemplateMethod Visitor
下載所有示例代碼和文檔 From www.niufish.com.
感謝Christopher Alexander,他把模式這一概念帶入我們視線。我們希望模式能夠給我們帶來:復(fù)用解決方案、建立通用的術(shù)語、設(shè)計上的高層次視角……
模式只是武功套路。其實真正的內(nèi)功心法是:
TODO:升級備忘錄模式,并和命令模式配合完成Redo 和 undo功能
由于本人學(xué)識淺陋、水平有限,遺漏和失誤在所難免,請大家見諒,并歡迎各位指正和交流。
參考:
《Java與模式》 閻宏 ISBN:7-5053-8000-1/TP.4653
《設(shè)計模式精解 Design Patterns Explained》 熊節(jié) 譯 ISBN:7-302-09841-7
《設(shè)計模式迷你手冊》 RedSwork軟件工作室