Design Pattern (1) - Introduction

What is a design pattern?

  Software developers summed up in long-term practice to solve a specific problem with a solution.

Object Design Principles

Meter model is mainly based on the following principles of object-oriented design.

  • Rather than on programming interface for programming.
  • Priority object composition rather than inheritance.

Six principles of design patterns

1, the opening and closing principle (Open Close Principle, OCP)

 Open for extension, but closed for modification . The key step is to abstraction, using abstract classes and interfaces to business abstract base class, so that when the program needs to be expanded, not to modify the original code, adding new modules to achieve the effect of a hot-swappable.

2, Richter substitution principle (Liskov Substitution Principle, LSP)

Simple to understand, subclass replacement parent class, subclass specific abstract parent class implementation. LSP and OCP complement each other.

3. Dependency Inversion Principle (Dependence Inversion Principle, DIP)

This principle is the basis of the principle of opening and closing, the specific content: for interface programming, depend on the abstract rather than relying on specific.

4, the interface segregation principle (Interface Segregation Principle, ISP)

Single responsibility principle similar to the method, an interface do one thing, to reduce the coupling between classes, i.e., a plurality of interface isolation, is better than using a single interface

5, Demeter, also known as the least known principle (Demeter Principle, DP)

Allow the system to remain relatively independent functional modules, an entity should try to complete the task independently, do not interact with other entities as possible between.

6, the synthesis of multiplexing principles (Composite Reuse Principle)

Blocks, then thought to make use of synthetic polymeric ways /, instead of using inheritance.

Design mode type

Common design pattern 25 species. These patterns can be divided into three categories:

  (1) create a schema (Creational Patterns) 

  (2) structural model (Structural Patterns)

  (3) type of model (Behavioral Patterns)

Creating type (five kinds)

  • Factory pattern (Factory Pattern)
  • Abstract Factory (Abstract Factory Pattern)
  • Singleton (Singleton Pattern)
  • Builders mode (Builder Pattern)
  • Prototype model (Prototype Pattern)

Structural model (8 types)

  • Adapter mode (Adapter Pattern)
  • Bridge mode (Bridge Pattern)
  • Filter mode (Filter, Criteria Pattern)
  • Combined mode (Composite Pattern)
  • Decorator (Decorator Pattern)
  • Appearance Model (Facade Pattern)
  • Flyweight (Flyweight Pattern)
  • Agent mode (Proxy Pattern)

 Behavioral patterns (12 kinds)

  • Chain of Responsibility pattern (Chain of Responsibility Pattern)
  • Command Mode (Command Pattern)
  • Interpreter pattern (Interpreter Pattern)
  • Iterator pattern (Iterator Pattern)
  • Intermediary model (Mediator Pattern)
  • Memo mode (Memento Pattern)
  • The observer pattern (Observer Pattern)
  • Mode state (State Pattern)
  • Null Object mode (Null Object Pattern)
  • Strategy Mode (Strategy Pattern)
  • Template mode (Template Pattern)
  • Visitor pattern (Visitor Pattern)

 

Guess you like

Origin www.cnblogs.com/lfhappy/p/10948457.html