C++ design pattern template classification

1. Model classification from the perspective of packaging changes

1. Component collaboration
  • Template Method
  • Strategy
  • Observer / Event
2. Single responsibility
  • Decorator
  • Bridge
3. Object creation
  • Factory Method
  • Abstract Factory
  • Prototype
  • Builder
4. Object performance
  • Singleton
  • Flyweight
5. Interface isolation
  • Facade
  • Proxy
  • Mediator
  • Adapter
6. Status changes
  • Memento
  • State
7. Data Structure
  • Composite
  • Iterator
  • Chain of Responsibility
8. Behavior changes
  • Command
  • Visitor
9. Field changes
  • Interpreter

2. Refactoring to Patterns

  • Good object-oriented design: refers to a design that can meet "response to changes and improve reuse";
  • "Frequent changes in requirements", "find points of change" and then apply design patterns at the points of change, so as to better cope with changes in requirements. "When and where to apply design patterns" is more important than "understanding the structure of design patterns" important ;
  • The application of design patterns should not be preconceived. Refactoring to Patterns

3. Reconstruction of key techniques (Guiding ideology)

  • Static to dynamic
  • Early binding to late binding
  • Inherit to combination
  • Compile-time dependency to runtime dependency
  • Tightly coupled to loosely coupled

Guess you like

Origin blog.csdn.net/weixin_40437821/article/details/111462516