Single Responsibility Principle)
Each object in the system should have only one separate responsibility, and all objects are concerned with the completion of their own responsibilities.
A reasonable class provides only one function, and there should be only one reason for class changes.
Liskov Substitution Principle)
Any parent class can be replaced by its subclass.
Objects in the same inheritance system should have common behavior characteristics.
The Lee's replacement principle focuses on how to use inheritance well. That is to say, do not abuse inheritance. It is the cornerstone of inheritance reuse.
Dependence Inversion Principle)
In an application, if all classes are used or dependent on other classes, they should be dependent on the abstract classes of these other classes, rather than the specific implementation classes of these other classes.
Abstract layers should not depend on specific implementation details to ensure system reusability and maintainability.
The essence of the dependency injection principle is to make the implementation of each class or module independent from each other through abstraction (abstract class or excuse), so as to achieve loose coupling between modules.
Interface Segregation Principle)
An interface does not need to provide too many behaviors. It should only provide one external function (the interface here is not only an interface defined by the interface keyword, but also an object interface, for example, Phone phone = new Phone ())
The interface separation principle requires that a module only depends on the interfaces It needs. This requires that the interface should be refined as much as possible during interface design.
The interface separation principle is similar to the single responsibility principle. The difference is that the single responsibility principle requires a single class and interface responsibility, focuses on the responsibility, and is the division of business logic; the interface separation principle requires as few interface methods as possible and as useful as possible for a module
Law Of Demeter)
An object should be less familiar with other objects, which means to reduce the coupling between objects and improve the maintainability of the system.
Communication between modules should only be through interfaces, regardless of the internal working principle of the module. It can minimize the Coupling Degree of each module and promote software reuse.
Open for Extension, Closed for Modification)
Objects should be open to extensions and closed to modifications
Changes to the class are made by adding code instead of modifying the existing code.
That is to say, once a developer writes code that can be run, it should not be changed. This needs to be implemented by means of abstraction and polymorphism, that is, to abstract the content that may change, so that the abstract part is relatively stable, and the specific implementation can be changed and expanded.