Java設計模式

設計模式簡介

設計模式(Design pattern)表明了最佳的實踐,一般被有經驗的面向對象的軟件開發人員所採用。設計模式是軟件開發人員在軟件開發過程當中面臨的通常問題的解決方案。這些解決方案是衆多軟件開發人員通過至關長的一段時間的試驗和錯誤總結出來的。html

設計模式是一套被反覆使用的、多數人知曉的、通過分類編目的、代碼設計經驗的總結。使用設計模式是爲了重用代碼、讓代碼更容易被他人理解、保證代碼可靠性。前端

設計模式的類型

根據設計模式的參考書 Design Patterns - Elements of Reusable Object-Oriented Software(中文譯名:設計模式 - 可複用的面向對象軟件元素) 中所提到的,總共有 23 種設計模式。這些模式能夠分爲三大類:建立型模式(Creational Patterns)、結構型模式(Structural Patterns)、行爲型模式(Behavioral Patterns)。還有表層設計模式:J2EE設計模式。設計模式

 

序號

 

模式 & 描述ui

包括
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)

(以上參考文獻來自runoob.com教程 原文連接:https://www.runoob.com/design-pattern/design-pattern-intro.html)spa

相關文章
相關標籤/搜索