Charpter05 Dependency Inversion principle

Dependency Inversion principle Introduction

Rely on the reverse principle: the abstract should not rely on the details, it should have been dependent on the abstract.

To an interface for programming, and should not be programmed to achieve.

Richter substitution principle: subtype must be able to replace their parent type. Only when the subclass can replace the parent class, functional software unit is not affected, the parent can really be multiplexed. The subclass can also add new features on the basis of the parent class.

 

 It is because in an alternative type makes use of the parent class type of module can be extended without modifying the situation at the time.

Rely on the reverse in fact, can be said to be object-oriented design of the logo, which language to write programs is not important, consider if writing is how to program for the abstract rather than to the details of programming that all dependencies are terminated in the program abstract class or interface, it is object-oriented design, the contrary is of the design process.

Guess you like

Origin www.cnblogs.com/yb-blogs/p/12499379.html