[Mode] design concepts, principles and classification

Design Patterns dim

Design patterns are set to be used repeatedly, most people know, after cataloging, code design experience summary. Use design patterns to reuse code, make the code easier to understand others, to ensure the reliability of the code.

Design pattern has been developing for a long period of time, they provide the best solutions to common problems faced by the software development process. These learning mode helps inexperienced developer through a quick and easy way to learn the software design.

The general idea is: high cohesion, low coupling.


Principles of design patterns: SOLID

Abbreviation Full name meaning
SICKLE The Single Responsibility Principle Single Responsibility Principle
OCP The Open Closed Principle Open Closed Principle
LSP The Liskov Substitution Principle Richter substitution principle
ISP The Interface Segregation Principle The principle of separation Interface
DIP The Dependency Inversion Principle Dependency Inversion Principle
  • Single Responsibility : a class or object reflects only one type of feature or only do one thing or a group of related things;
  • Open closed : open for extension, but closed for modification. When the program needs to be extended, so as not to modify the existing code.
  • Richter replaced : where any base class can appear, sub-class will be able to appear. LSP is inherited cornerstone multiplexed only when the derived class can replace the base class, and the software unit of functionality is not affected, the base class can really be reused, and the derived class can add new on the basis of the base class on behavior. Richter substitution principle is the principle of complementarity closed off. Implement the principle of opening and closing is a key step in abstraction, inheritance and base class and sub-class is the abstract concrete realization, so Richter substitution principle is the specification for concrete steps to achieve the abstract.
  • Interface Separation : using a plurality of isolated interface, rather than using a single interface.
  • Rely on the reverse : the face of programming interfaces, depending on the abstract rather than relying on specific. This is the basis of the principle of opening and closing.
    There are two:
  • Demeter, also known as the least known principles (Demeter Principle): an entity should interact as little as possible between the entity and the other, so that the system is relatively independent function modules.
  • Synthesis multiplexing (Composite Reuse Principle): a way to make use of synthetic polymeric / instead of inheritance.

Classification of design patterns

Create a schema

These designs provide a way to hide the pattern created while creating a logical object, rather than directly instantiated objects using the new operator. This makes the program more flexible when determining which objects need to be created for a given instance.

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

These design patterns focus on a combination of classes and objects. The concept of inheritance is used to define a combination of interfaces and combinations of new features of the object.

  • 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

The design mode is particularly concerned about the communication between objects.

  • 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)


Author: maxwellyue
link: https: //www.jianshu.com/p/a97ed9bcd60f
Source: Jane books

Guess you like

Origin www.cnblogs.com/xiaoshen666/p/11258573.html