Lying design pattern ---- Design Principles

A single responsibility principle (SRP)  

       Definition: On a category, it should only be one the cause of change.

  If a class too many responsibilities to bear, it means these functions coupled together, a change in responsibilities may weaken or inhibit the ability of this class perform other duties. This coupling will lead to fragile designs, when a change occurs, the design will suffer unexpected damage.

 

Second, the open - closed principle

  Definition: software entities (classes, modules, functions, etc.) should be extended, but not modified. For open for extension, closed for change.

  When originally encoded, assuming no change. When changes occur, we will create an abstract to isolate similar changes in the future. The face of demand changes to the program is carried out by adding new code, rather than changing existing code.

  Open - closed principle is the core of object-oriented design. Following this principle can bring enormous benefits of object-oriented technology claimed, that is maintainable, scalable, reusable, good flexibility. Developers should only program showing those parts of the frequent changes made abstract,

For each part of the application are deliberately abstract same is not a good idea. As important as immature denial of abstraction and abstraction itself.

 

Third, the Dependency Inversion principle

  Definition: high-level modules should not be the bottom module, both of which should rely on abstract; abstract should not rely on the details, the details should depend abstract; to be an interface for programming, not to implement programming.

 

Fourth, Richter substitution principle

  Definition: If you are using a software entity is a parent, then it must apply its subclass, subtype must be able to replace their parent.

 

To be continued. . .

 

Guess you like

Origin www.cnblogs.com/zsmcwp/p/11622482.html