簡介:
設計模式是軟件開發人員在軟件開發過程中面臨的一般問題的解決方案。這些解決方案是衆多軟件開發人員經過相當長的一段時間的試驗和錯誤總結出來的。使用設計模式是爲了重用代碼、讓代碼更容易被他人理解、保證代碼可靠性。
設計模式的類型:
1 創建型模式
這些設計模式提供了一種在創建對象的同時隱藏創建邏輯的方式,而不是使用 new運算符直接實例化對象。這使得程序在判斷針對某個給定實例需要創建哪些對象時更加靈活。
- 工廠模式(Factory Pattern)
- 抽象工廠模式(Abstract Factory Pattern)
- 單例模式(Singleton Pattern)
- 建造者模式(Builder Pattern)
- 原型模式(Prototype Pattern)|
2 結構型模式
這些設計模式關注類和對象的組合。繼承的概念被用來組合接口和定義組合對象獲得新功能的方式。
- 適配器模式(Adapter Pattern)
- 橋接模式(Bridge Pattern)
- 過濾器模式(Filter、Criteria Pattern)
- 組合模式(Composite Pattern)
- 裝飾器模式(Decorator Pattern)
- 外觀模式(Facade Pattern)
- 享元模式(Flyweight Pattern)
- 代理模式(Proxy Pattern)
3 行爲型模式
這些設計模式特別關注對象之間的通信。
- 責任鏈模式(Chain of Responsibility Pattern)
- 命令模式(Command Pattern)
- 解釋器模式(Interpreter Pattern)
- 迭代器模式(Iterator Pattern)
- 中介者模式(Mediator Pattern)
- 備忘錄模式(Memento Pattern)
- 觀察者模式(Observer Pattern)
- 狀態模式(State Pattern)
- 空對象模式(Null Object Pattern)
- 策略模式(Strategy Pattern)
- 模板模式(Template Pattern)
- 訪問者模式(Visitor Pattern)
4 J2EE 模式
這些設計模式特別關注表示層。這些模式是由 Sun Java Center 鑑定的。
- MVC 模式(MVC Pattern)
- 業務代表模式(Business Delegate Pattern)
- 組合實體模式(Composite Entity Pattern)
- 數據訪問對象模式(Data Access Object Pattern)
- 前端控制器模式(Front Controller Pattern)
- 攔截過濾器模式(Intercepting Filter Pattern)
- 服務定位器模式(Service Locator Pattern)
- 傳輸對象模式(Transfer Object Pattern)