目錄
設計模式
設計模式分爲三大類:創建型模式(Creational Patterns)、結構型模式(Structural Patterns)、行爲型模式(Behavioral Patterns)。主要是基於以下的面向對象設計原則:
- 對接口編程而不是對實現編程。
- 優先使用對象組合而不是繼承。
設計模式的類型
序號 | 模式 & 描述 | 包括 |
---|---|---|
1 |
創建型模式 優點:程序在判斷針對某個給定實例需要創建哪些對象時更加靈活。 |
工廠模式(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) |
設計模式的關係