- 講述如何從“過程式”編碼轉(zhuǎn)為“面向?qū)ο笫健本幋a谜慌。
- “過程式”編碼的一個顯著特征就是方法或類巨大兰珍,比如方法體邏輯復(fù)雜温亲,從而超過 200 行,類超過 1000 行匕得;其他特征有继榆, 繁多或嵌套的 if...else 語句。
- 業(yè)務(wù)邏輯的復(fù)雜度不應(yīng)該影響設(shè)計的合理性汁掠。比如略吨,即便是很簡單的業(yè)務(wù)邏輯,也應(yīng)劃分清楚其所屬位置考阱,特別是應(yīng)用到前后端分離的系統(tǒng)中時翠忠。
類型 | 模式名稱 | 學(xué)習(xí)難度 | 使用頻率 |
---|---|---|---|
創(chuàng)建型模式 Creational Pattern | 單例模式Singleton Pattern | ★☆☆☆☆ | ★★★★☆ |
創(chuàng)建型模式 Creational Pattern | 簡單工廠模式 Simple Factory Pattern | ★★☆☆☆ | ★★★☆☆ |
創(chuàng)建型模式 Creational Pattern | 工廠方法模式 Factory Method Pattern | ★★☆☆☆ | ★★★★★ |
創(chuàng)建型模式 Creational Pattern | 抽象工廠模式 Abstract Factory Pattern | ★★★★☆ | ★★★★★ |
創(chuàng)建型模式 Creational Pattern | 原型模式 Prototype Pattern | ★★★☆☆ | ★★★☆☆ |
創(chuàng)建型模式 Creational Pattern | 建造者模式 Builder Pattern | ★★★★☆ | ★★☆☆☆ |
結(jié)構(gòu)型模式 Structural Pattern | 適配器模式 Adapter Pattern | ★★☆☆☆ | ★★★★☆ |
結(jié)構(gòu)型模式 Structural Pattern | 橋接模式 Bridge Pattern | ★★★☆☆ | ★★★☆☆ |
結(jié)構(gòu)型模式 Structural Pattern | 組合模式 Composite Pattern | ★★★☆☆ | ★★★★☆ |
結(jié)構(gòu)型模式 Structural Pattern | 裝飾模式 Decorator Pattern | ★★★☆☆ | ★★★☆☆ |
結(jié)構(gòu)型模式 Structural Pattern | 外觀模式 Fa?ade Pattern | ★☆☆☆☆ | ★★★★★ |
結(jié)構(gòu)型模式 Structural Pattern | 享元模式 Flyweight Pattern | ★★★★☆ | ★☆☆☆☆ |
結(jié)構(gòu)型模式 Structural Pattern | 代理模式 Proxy Pattern | ★★★☆☆ | ★★★★☆ |
行為型模式 Behavioral Pattern | 職責(zé)鏈模式 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 | 狀態(tài)模式 State Pattern | ★★★☆☆ | ★★★☆☆ |
行為型模式 Behavioral Pattern | 策略模式 Strategy Pattern | ★☆☆☆☆ | ★★★★☆ |
行為型模式 Behavioral Pattern | 模板方法模式 Template Method Pattern | ★★☆☆☆ | ★★★☆☆ |
行為型模式 Behavioral Pattern | 訪問者模式 Visitor Pattern | ★★★★☆ | ★☆☆☆☆ |
根據(jù)目的和范圍對設(shè)計模式進(jìn)行分類
設(shè)計模式類圖