<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 從招式與內功談起——設計模式概述(二) 1.2 設計模式是什么 俗話說:站在別人的肩膀上,我們會看得更遠。設計模式的出現可以讓我們站在前人的肩膀上,通過一些成熟的設計方案來指導新項目的開發和設計,以便于我們開發出具有更好的靈活性和可擴展性,也更易于復用的軟件系統。 設計模式的一般定義如下: 設計模式(Design Pattern)是一套被反復使用、多數人知曉的、經過分類編目的、代碼設計經驗的總結,使用設計模式是為了可重用代碼、讓代碼更容易被他人理解并且保證代碼可靠性。 狹義的設計模式是指GoF在《設計模式:可復用面向對象軟件的基礎》一書中所介紹的23種經典設計模式,不過設計模式并不僅僅只有這23種,隨著軟件開發技術的發展,越來越多的新模式不斷誕生并得以應用。 設計模式一般包含模式名稱、問題、目的、解決方案、效果等組成要素,其中關鍵要素是模式名稱、問題、解決方案和效果。模式名稱(Pattern Name)通過一兩個詞來描述模式的問題、解決方案和效果,以便更好地理解模式并方便開發人員之間的交流,絕大多數模式都是根據其功能或模式結構來命名的(GoF設計模式中沒有一個模式用人名命名,微笑);問題(Problem)描述了應該在何時使用模式,它包含了設計中存在的問題以及問題存在的原因;解決方案(Solution)描述了一個設計模式的組成成分,以及這些組成成分之間的相互關系,各自的職責和協作方式,通常解決方案通過UML類圖和核心代碼來進行描述;效果(Consequences)描述了模式的優缺點以及在使用模式時應權衡的問題。 雖然GoF設計模式只有23個,但是它們各具特色,每個模式都為某一個可重復的設計問題提供了一套解決方案。根據它們的用途,設計模式可分為創建型(Creational),結構型(Structural)和行為型(Behavioral)三種,其中創建型模式主要用于描述如何創建對象,結構型模式主要用于描述如何實現類或對象的組合,行為型模式主要用于描述類或對象怎樣交互以及怎樣分配職責,在GoF 23種設計模式中包含5種創建型設計模式、7種結構型設計模式和11種行為型設計模式。此外,根據某個模式主要是用于處理類之間的關系還是對象之間的關系,設計模式還可以分為類模式和對象模式。我們經常將兩種分類方式結合使用,如單例模式是對象創建型模式,模板方法模式是類行為型模式。 值得一提的是,有一個設計模式雖然不屬于GoF 23種設計模式,但一般在介紹設計模式時都會對它進行說明,它就是簡單工廠模式,也許是太“簡單”了,GoF并沒有把它寫到那本經典著作中,不過現在大部分的設計模式書籍都會對它進行專門的介紹。 表1列出將要介紹的24種設計模式,其中模式的學習難度是我個人在多年模式使用和推廣過程中的經驗總結,僅作參考,模式的使用頻率來自著名的模式推廣和教育網站——http://www.dofactory.net。 表1 常用設計模式一覽表 | 類型 | 模式名稱 | 學習難度 | 使用頻率 | |---------------------------------|:---------------------------------------------:|---------:|----------| | 創建型模式 Creational Pattern | 單例模式 Singleton Pattern | ★☆☆☆☆ | ★★★★☆ | | 創建型模式 Creational Pattern | 簡單工廠模式 Simple Factory Pattern | ★★☆☆☆ | ★★★☆☆ | | 創建型模式 Creational Pattern | 工廠方法模式 Factory Method Pattern | ★★☆☆☆ | ★★★★★ | | 創建型模式 Creational Pattern | 抽象工廠模式 Abstract Factory Pattern | ★★★★☆ | ★★★★★ | | 創建型模式 Creational Pattern | 原型模式 Prototype Pattern | ★★★☆☆ | ★★★☆☆ | | 創建型模式 Creational Pattern | 建造者模式 Builder Pattern | ★★★★☆ | ★★☆☆☆ | | 結構型模式 Structural Pattern | 適配器模式 Adapter Pattern | ★★☆☆☆ | ★★★★☆ | | 結構型模式 Structural Pattern | 橋接模式 Bridge Pattern | ★★★☆☆ | ★★★☆☆ | | 結構型模式 Structural Pattern | 組合模式 Composite Pattern | ★★★☆☆ | ★★★★☆ | | 結構型模式 Structural Pattern | 裝飾模式 Decorator Pattern | ★★★☆☆ | ★★★☆☆ | | 結構型模式 Structural Pattern | 外觀模式 Fa?ade Pattern | ★☆☆☆☆ | ★★★★★ | | 結構型模式 Structural Pattern | 享元模式 Flyweight Pattern | ★★★★☆ | ★☆☆☆☆ | | 結構型模式 Structural Pattern | 代理模式 Proxy Pattern | ★★★☆☆ | ★★★★☆ | | 行為型模式 Behavioral Pattern | 職責鏈模式 Chain of Responsibility Pattern | ★★★☆☆ | ★★☆☆☆ | | 行為型模式 Behavioral Pattern | 命令模式 Command Pattern | ★★★☆☆ | ★★★★☆ | | 行為型模式 Behavioral Pattern | 解釋器模式 Interpreter Pattern | ★★★★★ | ★☆☆☆☆ | | 行為型模式 Behavioral Pattern | 迭代器模式 Iterator Pattern | ★★★☆☆ | ★★★★★ | | 行為型模式 Behavioral Pattern | 中介者模式 Mediator Pattern | ★★★☆☆ | ★★☆☆☆ | | 行為型模式 Behavioral Pattern | 備忘錄模式 Memento Pattern | ★★☆☆☆ | ★★☆☆☆ | | 行為型模式 Behavioral Pattern | 觀察者模式 Observer Pattern | ★★★☆☆ | ★★★★★ | | 行為型模式 Behavioral Pattern | 狀態模式 State Pattern | ★★★☆☆ | ★★★☆☆ | | 行為型模式 Behavioral Pattern | 策略模式 Strategy Pattern | ★☆☆☆☆ | ★★★★☆ | | 行為型模式 Behavioral Pattern | 模板方法模式 Template Method Pattern | ★★☆☆☆ | ★★★☆☆ | | 行為型模式 Behavioral Pattern | 訪問者模式 Visitor Pattern | ★★★★☆ | ★☆☆☆☆ |
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看