[Design Pattern] Summary of Design Pattern(to be continued)

摘要:[Design Pattern] Summary of Design Pattern(to be continued)

Before Patterns

Design is not just what it looks like and feels like. design is how it works. - Steve Jobs

Design is to design a design to produce a design.

Selection is not design, design is a decision.

OOD Six Essentials

  • Class, Object, Instance
  • Interface
  • Inheritance
  • Polymorphism
  • Composition
  • Delegation

OOD Six Principle

  • 模組化
  • 少耦合多內聚
  • 找出hot spot
  • 多樣性原則
  • Progamming to an Interface, not an Implementation
  • Favor object composition over class inheritance

Design Patterns Intro

  • 一再重複出現的東西、事件、現象、行為都可稱為模式
  • Each pattern is a three-part rule:context, problem, solution=> A pattern is a proven solution to a recurring problem in a specific context, and more.
    • Context(內容-解決前)
    • Problem(問題本身)
    • Forces(作用力-問題的限制或特性)
    • Solution(解決問題的方法)
    • Resulting Context(解決後之內容-套用解決方法後的結果)

依據用途,設計模式可分為三大類

  • Creational Patterns (生成模式)
    • Abstract Factory
    • Builder
    • Factory Method
    • Prototype
    • Singleton
  • Structural Patterns (結構模式)
    • Adapter
    • Bridge
    • Composite
    • Decorator
    • Façade
    • Flyweight
    • Proxy
  • Behavioral Patterns (行為模式)
    • Chain of Responsibility
    • Command
    • Interpreter
    • Iterator
    • Mediator
    • Memento
    • Observer
    • State
    • Strategy
    • Template Method
    • Visitor

依據內部關係,設計模式可分為另 外三大類

  • Abstract Coupling (抽象耦合)
    • State
    • Factory Method
    • Observer
    • Bridge
    • Builder
    • Command
    • Iterator
    • Visitor
    • Interpreter
    • Mediator
    • Adapter
    • Prototype
    • Proxy
    • Strategy
  • Recursive Structures (遞迴結構)
    • Composite
    • Chain of Responsibility
    • Decorator
  • Other Patterns (其他)
    • Abstract Factory
    • Flyweight
    • Singleton
    • Template Method
    • Memento

GoF書的23個設計模式

  • 5個生成模式 – Abstract Factory, Builder, Factory Method, Prototype, Singleton
  • 7個結構模式 – Adapter, Bridge, Composite, Decorator, Façade, Flyweight, Proxy
  • 11個行為模式 – Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor

Other

two compare

參考資源


如果覺得文章還不錯麻煩請在文章最上面給予推薦,你的支持是小弟繼續努力產出的動力!