--7 principles of design patterns

Seven principles of design patterns, in which to jot something, think of it and then update

Design mode, the right is the best.

1  closing Principle
 2  Richter Alternatively Principle
 3  Dependency Inversion Principle
 4  single responsibility
 5  Interface Segregation Principle
 6  Dimitris principle
 7 Synthesis of multiplexing principles

1, the principle of opening and closing

  Open for extension, but closed for modification. Abstract constraints, packaging changes. Regular abstract framework, variations embodied by a part of the package achieved.

2, Richter substitution principle

  Opening and closing the principle of complementarity, subclass inherits the parent, the parent class can be invoked on behalf of a subclass. Rational use of inheritance

3, Dependency Inversion Principle

  Executives should not rely on low-level, abstract should not depend on the details. Oriented programming interface, implementation class to the details, rather than programming-oriented implementation.

4, single responsibility

  Responsibilities to a single. A class best, only a change in the cause of it, otherwise consider splitting.

5. Interface Segregation Principle

  Interface to streamline single. When the behavior of an interface too much, consider splitting interface.

6, Dimmit principle

  Do not talk to strangers, speaking only with friends. Friends refers to the current class, members of the current class creates an instance and instance.

7, synthesis of the multiplexing principles

  Polymerization multiplexing principle, if keep talking to strangers, using a combination of methods to establish contact with other classes.

  Using inheritance subject to the Richter substitution principle when multiplexing.

  Multiplexing polymerization, Richter alternatively be opened and closed principles embodied

The principle of opening and closing in the "open for extension, but closed for modification" is the central idea.

Design patterns try to follow these principles. Between principles are closely linked, these links constitute a design patterns and apply them to the appropriate scene.

 

Guess you like

Origin www.cnblogs.com/xiaojieblog/p/11941287.html