Design Patterns - seven design principles

1. Single Responsibility Principle

2, the interface segregation principle

3, Dependency Inversion principle

  • Interface transfer
  • Passing the resulting
  • setter way of passing

4, Richter substitution principle

  • Subclass transparent

5, the principle of opening and closing

  • Extended opening
  • Modify Close

6, Demeter

  • Reduce the coupling between the class and class (reduce rather than eliminate)
  • At least know the principle (of their dependent classes know, the better)
  • Member variables, anti-party argument, the method return value is "friend", a local variable is not

7, synthesis of the multiplexing principles

  • Manner to make use of synthetic polymeric / instead of inheritance
  • Is a class dependent on the transmission method (use)
  • Aggregation is another class declared in a class, the method using the set assignment
  • Combination is in a class out of a class instantiated

The core idea of ​​design principles

  • Identify local applications may need to change them independent, and do not need to change the code of those mixed
  • For interface programming, rather than programming
  • For interactive objects between loosely coupled design efforts

Guess you like

Origin www.cnblogs.com/lovestart/p/11227303.html