Six principles of design patterns

Single Responsibility Principle (SRP)

There should be only one reason for a class to change.

Open Close Principle (OCP)

Objects in software (classes, modules, functions, and so on) should be open for extension but closed for modification. An important means of following the open close principle is through abstraction

Liskov Substitution Principle (LSP)

All references to base classes must be able to transparently use their subclasses’ open/close and Reefer substitution principles, which are often interdependent, to achieve the effect of being open for extension and closed for modification. Both of these principles emphasize an important feature of OOP — abstraction. Therefore, the use of abstraction in the development process is an important step towards code optimization.

Dependence Inversion Principle (DIP)

The dependency inversion principle refers to a particular form of decoupling in which the dependency modules are reversed so that high-level modules are not dependent on low-level modules for implementation details purposes. A few key points of the dependency inversion principle:

A high-level module should not depend on a low-level module; both should depend on its abstraction; Abstraction should not depend on details; Details should depend on abstractions.

Interface Segregation Principle (ISP)

Definition: Clients should not rely on interfaces they do not need. Or definition: Dependencies between classes should be on the smallest interface. The interface isolation principle breaks down very large, bloated interfaces into smaller and more specific ones so that customers will only know the methods they are interested in. The purpose of interface isolation is to decouple systems so they can be easily refactored, changed, and redeployed.

Uncle Bob (Robert C Martin) defined these five principles as SOLID principles in the early 21st century. As the five basic principles of object-oriented programming. When used together, these principles make a software system clearer, simpler, and more open to change. SOLID is typically used in test-driven development and is an important part of the basic principles of agile development and adaptive software development. These principles ultimately boil down to the key words: abstraction, single responsibility, minimization.

In addition to the above principles, there is a Demeter principle.

Law of Demeter (LOD) or Least Knowledge Principle (LKP)

Definition: An object should Only talk to your immedate friends with minimal knowledge of other objects. The system has lower coupling and better expansibility.

Excerpted from the “Android source code design pattern – analysis and combat” the author summarized very well, interested can go to read a book.