Design Patterns Study Notes (a) - six principles and three types

1.1 six principles (general principles - the principle of opening and closing: open for extension, closed for modification.)

  1. Single Responsibility Principle
    • Do not type more than one cause of change, which means that each class should implement a single responsibility, otherwise it should split the class.
  2. Richter substitution principle (Liskov Substitution Principle)
    • Supplement - "closed on" the principle of
    • Inheritance is the cornerstone of reuse: where any base class can appear, sub-class will be able to appear.
  3. Dependency Inversion principle (Dependence Inversion Principle)
    • Oriented programming interface, dependent on the abstract does not depend on the specific
  4. Interface Segregation Principle (Interface Segregation Principle)
    • Each interface does not exist in subclasses, but not by the method to be implemented, if otherwise, it is necessary to split the interface
  5. Demeter (the least known principle) (Demeter Principle)
    • A class of their dependent classes know, the better
    • Another expression of the least known principle is: only direct communication with friends.
      As long as there is coupling relationship called friendship between classes. Coupling into dependency, association, aggregation, and the like combinations.
      We call appears as a member variable, method arguments, method return values directly in the class friends.
      Local variables, temporary variables are not direct friends. We ask strangers class do not appear as a local variable in the class.
  6. Synthesis of multiplexing principles (Composite Reuse Principle)
    • Try first synthetic polymeric info / instead of inheritance.

1.2 three types

  1. Creator mode (Creational Pattern)
    • Examples of process for the abstract class, can be used to create software modules and objects in the object separation
  2. Structural model (Structural Pattern)
    • Describes how to combine together to form a larger class of objects or structures;
    • Class can be divided into structural model and object structures schema
  3. Behavioral patterns (Behavioral Pattern)
    • Not only concerned about the structure of classes and objects, but also focus on the interaction between them, and the algorithm is a division of responsibilities between the different objects of abstraction
    • Divided into two categories behavioral patterns and object behavioral patterns
    • The "Synthesis of multiplexing principles", the system should try to use the relationship inheritance substituted

Guess you like

Origin www.cnblogs.com/kintanx/p/11432233.html