Six Principles
It is often called SOLID+.
Single Responsibility Principle
Single Responsibility Principle (SRP)
A class does only one thing, and there should be one and only one reason to change the class.
Open and close principle
Open-Close Principle (OCP)
Classes and modules should be open for extension and closed for modification.
Liskov Substitution Principle
Liskov Substitution Principle (LSP)
All places that refer to the base class must be able to use its subclass objects transparently.
Interface Segregation Principle
Interface Segregation Principle (ISP)
A class’s dependence on another class should be established on the smallest interface, and it should not depend on and know the interface it does not need.
Dependency Inversion Principle
Dependency Inversion Principle (DIP)
High-level modules should not depend on low-level modules, both should depend on abstractions, abstractions should not depend on details, details depend on abstractions.
Law of Demeter
Law of Demeter (LOD)
Only talk to your immediate friends.
Also known as the Least Knowledge Principle (Least Knowledge Principle), a class should know the least about the classes it needs to couple or call, rely on as few interfaces as possible, and each interface contains only the required methods.