設計模式——C++(總)

目錄

設計模式

設計模式的類型

設計模式的關係


設計模式

設計模式分爲三大類:創建型模式(Creational Patterns)、結構型模式(Structural Patterns)、行爲型模式(Behavioral Patterns)。主要是基於以下的面向對象設計原則:

  • 接口編程而不是對實現編程。
  • 優先使用對象組合而不是繼承。

設計模式的類型

序號 模式 & 描述 包括
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)

 

設計模式的關係

 

在這裏插入圖片描述

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章