Recently, we have seen the shadows of design patterns in many occasions. We have been investing in algorithms and data structures for a long time. It is very important to find the design patterns. Sometimes code maintenance, reuse, and scalability are better than pure algorithms. So I picked up Daniel's book "big talk Design Patterns" and referred to the blogs of various big cows on the Internet to start my design patterns journey.
Today, we will introduce the dependency reversal principle.
Concept:
A. High-level modules do not depend on low-level modules and should all rely on abstraction;
B. abstraction should depend on details, and details should not depend on abstraction.
Explanation:
Here we need to mention the Lee's replacement principle: the Child type must be able to replace its parent type. A software is a place where basic objects appear in an object. It should be used for its derived object. The derived class inherits the base class and has all the members of the base class, and can expand its own attributes. High-level modules and low-level modules are implemented through interfaces or abstract classes, turning them into thinking: programming interfaces instead of implementing programming. Result