Design Patterns (1) - Design Principles

Design Principles

There are five principles say, six principles, the seven principles; it does not matter, it is important to understand what these principles are; design principles have a choice;

Open Closed Principle:

Definitions: As a software entity, module classes and functions should be open for extension but closed for modification.

Meaning the opening and closing principle is that: when changing needs of the application, without physical modification of the source code or software binary code can be extended function module, to meet the new demand

  • Achieve the expansion frame abstract the details of construction, with
  • Improve software reusability and maintainability

effect

Open Closed Principle is the ultimate goal of object-oriented programming, which makes software entities have a certain flexibility and adaptability along with stability and continuity. Specifically, its role is as follows.

1. The impact of software testing

Software to comply with the principle of opening and closing, then, requires only a software test code to test for extensions on it, because the original test code still works correctly.

2. improve the code reusability

The smaller the particle size, the greater the possibility of being multiplexed; in object-oriented programming, and the atomic abstract programming can improve code reusability.

3. You can improve software maintainability

Comply with the principle of opening and closing software, high stability and strong continuity, making it easy to extend and maintain.

The interface should be stable and reliable

Implementation

It may be achieved by "abstract constraint, the package changes" on-off principle, i.e. through the software interface or abstract class defines a relatively stable entity abstraction layer, and the same package variables embodied in the same class.

Because the abstract good flexibility and adaptability, as long as the abstract rational, can remain stable software architecture. The software details can be volatile born from the abstract implementation class to be extended when the software needs to change, only to re-implement a class derived according to the demand to extend it

 

 

Design Patterns eye

Guess you like

Origin www.cnblogs.com/Magic-Dev/p/11695345.html