JAVA Design Pattern Learning 2 - Object-Oriented Design Principles

The core of software design is to improve the reusability and maintainability of software. Usually the reason for the poor reusability and scalability of a software is that the design is too rigid, too fragile, the reuse rate is low, and the viscosity is too high. At this time, it is necessary to find ways to improve scalability, flexibility and pluggability. so as to improve the reusability and maintainability of the software. Generally, maintainability and reusability cannot achieve the purpose at the same time. Only by following certain design principles can the designed system satisfy both reusability and maintainability. The main principles of object-oriented design are as follows:

1. The "Open-Closed Principle" (OCP) for short, says that a software entity should be open for extension and closed for modification.

2. Liskov Substitution Principle (LSP) for short, says that any place where a parent class appears can be replaced by a subclass.

3. The Dependency INversion Principle (DIP) for short, refers to relying on abstraction rather than implementation.

4, Interface Segregation Principle (Interface Segregation Principle) referred to as ISP, is about providing the client with as small a separate interface as possible, rather than providing a large total interface.

5. The Composition/Aggregation Principle (CARP for short) refers to the use of composition and aggregation as much as possible to achieve the purpose of reuse instead of inheritance.

6. The Law of Demeter (LoD for short) states that a software entity should interact with as few other software entities as possible.

The reason why we need to talk about design principles before talking about design patterns is because design patterns are the specific guidance of object-oriented design principles, so with theory and design guidance, we can enter the study of design patterns. There are 23 design patterns that people often say, In fact, there are many more in reality, which can be roughly divided into three categories: creation mode, structure mode and behavior mode.

from:http://alaric.iteye.com/blog/1722198

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326720909&siteId=291194637