SOLID principles

Original please indicate the source: https://www.cnblogs.com/agilestyle/p/11444197.html

 

Single Responsibility (Single Responsibility)

Single Responsibility (Single Responsibility), or the object class is best to have a single responsibility, in programming if you find a class bear a variety of duties, consider split.

 

开关原则(Open-Close, Open for extension, close for modification)

Principles switch (Open-Close, Open for extension, close for modification), designed to be open for extension but closed for modification. In other words, the program should be designed to ensure smooth scalability, try to avoid because of similar new features and modifications have been achieved so little can yield some return (regression) problem.

 

Richter replacement (Liskov Substitution)

When Richter replacement (Liskov Substitution), which is one of the basic elements of object-oriented, relationship inherit the abstract, who can, can be replaced with a subclass with a parent or local base class.

 

Separation Interface (Interface Segregation)

Ports separated (Interface Segregation), we conduct classes and interfaces design, if you define too many methods in an interface, the subclasses are likely to face a dilemma, it is only part of the method is meaningful, which destroyed cohesive program.
For this case, the behavior can be decoupled by splitting a single Successful plurality of interfaces. In future maintenance, if the design of an interface change, will not affect the use of subclass other interfaces.

 

Dependency Inversion (Dependency Inversion)

Dependency Inversion (Dependency Inversion), an entity should depend on abstractions rather than implementation. That high-level modules should not depend on low-level modules, but should be based on the abstract. The practice of this principle is to ensure the proper degree of coupling between the product code of magic. Polymorphism, you might immediately think of rewriting (override) and heavy (overload), the transition upwards. Briefly, the method is to rewrite the parent-child class with the same name and parameters, different implementations; it is overloaded methods with the same name but different parameters, in essence, these methods are not the same signature

 

Guess you like

Origin www.cnblogs.com/agilestyle/p/11444197.html
Recommended