003設(shè)計模式--分類

分類說明

根據(jù)設(shè)計模式的參考書 Design Patterns - Elements of Reusable Object-Oriented Software(中文譯名:設(shè)計模式 - 可復(fù)用的面向?qū)ο筌浖兀?/strong> 中所提到的,總共有 23 種設(shè)計模式。這些模式可以分為三大類:

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

    工廠模式(Factory Pattern)
    抽象工廠模式(Abstract Factory Pattern)
    單例模式(Singleton Pattern)
    建造者模式(Builder Pattern)
    原型模式(Prototype Pattern)
    
  • 結(jié)構(gòu)型模式: 這些設(shè)計模式關(guān)注類和對象的組合。繼承的概念被用來組合接口和定義組合對象獲得新功能的方式。

    適配器模式(Adapter Pattern)
    橋接模式(Bridge Pattern)
    組合模式(Composite Pattern)
    裝飾器模式(Decorator Pattern)
    外觀模式(Facade Pattern)
    享元模式(Flyweight Pattern)
    代理模式(Proxy Pattern)
    
    過濾器模式(Filter、Criteria Pattern)    --  非23鐘
    
  • 行為型模式: 這些設(shè)計模式特別關(guān)注對象之間的通信。

    責(zé)任鏈模式(Chain of Responsibility Pattern)
    命令模式(Command Pattern)
    解釋器模式(Interpreter Pattern)
    迭代器模式(Iterator Pattern)
    中介者模式(Mediator Pattern)
    備忘錄模式(Memento Pattern)
    觀察者模式(Observer Pattern)
    狀態(tài)模式(State Pattern)
    策略模式(Strategy Pattern)
    模板模式(Template Pattern)
    訪問者模式(Visitor Pattern)
    
    空對象模式(Null Object Pattern)    --  非23鐘
    

用一個圖片來整體描述一下設(shè)計模式之間的關(guān)系:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容