Six principles of design pattern 1, opening and closing principle (Open close principle) The opening and closing principle means: open to expansion, close to modification. When the program needs to expand, can not modify the original code, to achieve a hot-swappable effect. In short, this is to make the program more scalable and easy to maintain and upgrade. To achieve this, we need to use interfaces and abstract classes, which we'll refer to later in the specific design. 2, the Richter substitution principle (Liskov substitution principle) The principle of the Richter substitution is one of the basic principles of object-oriented design. The Richter substitution principle says that where any base class can appear, subclasses must be present. LSP is the cornerstone of inheritance reuse, and only if the derived class can replace the base class, and the functionality of the Software Unit is not affected, the base class can be truly reused, and derived classes can add new behavior based on the base class. The principle of the Richter substitution is a supplement to the principle of closing off. The key step of realizing the opening and closing principle is abstraction, and the inheritance relation of the base class and subclass is the concrete realization of abstraction, so the principle of the Richter substitution is the specification of the concrete steps to realize abstraction. 3. The principle of reliance reversal (dependence inversion principle) This principle is the basis of the open and closed principle, specific content: for the interface programming, rely on the abstract and not rely on the specific. 4. Interface Isolation principle (Interface segregation principle) This principle means that using multiple isolated interfaces is better than using a single interface. It also has another meaning: reduce the coupling between classes. This shows that, in fact, design pattern is from large software architecture, easy to upgrade and maintenance of software design ideas, it emphasizes reducing dependence, reduce coupling. 5, Dimitri Law, also known as the least known principle (Demeter principle) The least known principle is that an entity should interact with other entities as little as possible, making the system functional modules relatively independent. 6. Synthetic reuse principle (composite reuse principle) The composite reuse principle refers to the use of compositing/aggregation as much as possible, rather than using inheritance. |