php 設計模式

簡介:

設計模式是軟件開發人員在軟件開發過程中面臨的一般問題的解決方案。這些解決方案是衆多軟件開發人員經過相當長的一段時間的試驗和錯誤總結出來的。使用設計模式是爲了重用代碼、讓代碼更容易被他人理解、保證代碼可靠性。

設計模式的類型:

1 創建型模式

這些設計模式提供了一種在創建對象的同時隱藏創建邏輯的方式,而不是使用 new運算符直接實例化對象。這使得程序在判斷針對某個給定實例需要創建哪些對象時更加靈活。

  1. 工廠模式(Factory Pattern)
  2. 抽象工廠模式(Abstract Factory Pattern)
  3. 單例模式(Singleton Pattern)
  4. 建造者模式(Builder Pattern)
  5. 原型模式(Prototype Pattern)|
2 結構型模式

這些設計模式關注類和對象的組合。繼承的概念被用來組合接口和定義組合對象獲得新功能的方式。

  1. 適配器模式(Adapter Pattern)
  2. 橋接模式(Bridge Pattern)
  3. 過濾器模式(Filter、Criteria Pattern)
  4. 組合模式(Composite Pattern)
  5. 裝飾器模式(Decorator Pattern)
  6. 外觀模式(Facade Pattern)
  7. 享元模式(Flyweight Pattern)
  8. 代理模式(Proxy Pattern)
3 行爲型模式

這些設計模式特別關注對象之間的通信。

  1. 責任鏈模式(Chain of Responsibility Pattern)
  2. 命令模式(Command Pattern)
  3. 解釋器模式(Interpreter Pattern)
  4. 迭代器模式(Iterator Pattern)
  5. 中介者模式(Mediator Pattern)
  6. 備忘錄模式(Memento Pattern)
  7. 觀察者模式(Observer Pattern)
  8. 狀態模式(State Pattern)
  9. 空對象模式(Null Object Pattern)
  10. 策略模式(Strategy Pattern)
  11. 模板模式(Template Pattern)
  12. 訪問者模式(Visitor Pattern)
4 J2EE 模式

這些設計模式特別關注表示層。這些模式是由 Sun Java Center 鑑定的。

  1. MVC 模式(MVC Pattern)
  2. 業務代表模式(Business Delegate Pattern)
  3. 組合實體模式(Composite Entity Pattern)
  4. 數據訪問對象模式(Data Access Object Pattern)
  5. 前端控制器模式(Front Controller Pattern)
  6. 攔截過濾器模式(Intercepting Filter Pattern)
  7. 服務定位器模式(Service Locator Pattern)
  8. 傳輸對象模式(Transfer Object Pattern)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章