Object-oriented design principles and design patterns are also guidelines for the rational reconfiguration of the system, increasing our application maintainability and reusability Common object-oriented design principles include 7, these principles are not isolated, they depend on each other and complement each other. But keep in mind: "The open and closed principle is the goal, the Richter substitution principle is the basis, relies on the reversal principle is the means ", they complement each other, complement each other, below with a picture illustrates:
1. Single Responsibility PRINCIPLE,SRP: Classes have a single responsibility and cannot put too much responsibility in one class. (High cohesion, low coupling)
2. "Opening and closing principle " (Open-closedprinciple, OCP): Open for expansion, closed for modification ( core principles of design mode )
3. " Richter Substitution Principle " (Liskov Substitution Principle, LSP): Where any base class can occur, subclasses can also appear ( base )
4. " Dependency reversal Principle " (Dependence inversion Principle, DIP): Rely on abstraction rather than on specific implementations. Interface Programming ( means )
5. "Interface Isolation principle" (Interface segregation Principle, ISP): use multiple specialized interfaces instead of a single total interface, that is, the client should not rely on interfaces that it does not need.
6 ". Synthesis/Aggregation multiplexing principle" (Composite/aggregate reuseprinciple, CARP): To use object combinations as much as possible, rather than to achieve software reuse for inheritance relationships
7. "Law of Demeter,lod": Classes in the system, try not to Dimitri with other classes, reduce the degree of coupling between classes
Design pattern learning can refer to http://blog.csdn.net/lovelion/article/details/17517213
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Design Pattern 7 Principles Summary