Summary of design patterns in program development

In our daily development process, design patterns accompany each module of the project. Reasonable use of design patterns can allow us to write more efficient and concise code.

Talking about the advantages and disadvantages of design patterns

what are design patterns

Design patterns are solutions tailored to solve problems in specific scenarios.

advantage

  • Reasonable use of design patterns can reduce code coupling and improve code reuse rate
  • Reasonable use of design patterns can make the project structure clear
  • Reasonable use of timing patterns can make code easier to maintain

shortcoming

  • Using design patterns will increase the category and amount of code to a certain extent

Basic Principles of Design Patterns

Open Closed Principle (OCP)

Open for module extension, closed for modification, the code in the .m file does not change

Liskov Substitution Principle (LSP)

Where any class can appear, the subclass must appear, the subclass can be replaced with the parent class, and the subclass can use all the methods of the parent class

Polymorphism: Overriding parent class methods

Try not to rewrite the implementation logic of the parent class itself

Dependency Inversion Principle (DIP)

Abstraction does not depend on details, details depend on abstraction (usually referring to interfaces)

Interface Segregation Principle (ISP)

Only do necessary things in the interface, do not do other unrelated things

Composite, Aggregate Multiplexing Principle (CARP)

Extend another method from one class, try not to use inheritance, use other methods

Principle of Minimum Knowledge (PLK)

The two classes do not communicate directly with each other, but use another class to communicate

Single Responsibility Principle (SRP)

A class is responsible for only one functional area

Types of Design Patterns

  • GOF Design Patterns
  • Concurrency Design Patterns
  • Framework level design patterns

Classification of 23 Design Patterns

Creation mode: 5 types

  • factory pattern
  • Abstract Factory Pattern
  • builder mode
  • prototype mode
  • singleton pattern

Concurrency Design Patterns: 7

  • proxy mode
  • Combination mode
  • bridge mode
  • flyweight pattern
  • Appearance Mode
  • decorative pattern
  • adapter mode

Framework-level design patterns: 11

  • Observer pattern
  • visitor pattern
  • mediator model
  • Interpreter mode
  • strategy mode
  • iterator pattern
  • command mode
  • state mode
  • memo mode
  • Template method pattern
  • Chain of Responsibility Model

A brief introduction to design patterns in MVC

Design Patterns in MVC

These 23 design patterns commonly used in the process of program development are briefly introduced here, and the following blogs will introduce several commonly used design patterns one by one.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324662134&siteId=291194637