Dependency:
In the process of step-by-step refinement from top to bottom,
The solution of big problems depends on the solution of medium and small problems,
the solution of medium problems depends on the solution of small problems, the arrow points downwards to indicate the caller Depend on the provider.
The general dependency in the object-oriented process is:
The picture shows different drivers driving different cars.
But the fact is that one driver can drive a variety of vehicles, and the principle of dependency reversal is introduced.
Relying on the principle of reversal is another way of thinking, not a denial of the idea of gradual refinement from top to bottom.
When the Dirver class calls the drive method, the access is The Run method of IVehicle, and Car, Truck, etc. all implement the IVehicle interface.
In this way, Drive can open both Car and Truck. If it is a Car instance, it will call Run in Car, and if it is a Truck instance, it will call Run in Truck.
The same for the Driver:
< p>Extending further down is the content of the design pattern. PPT is taken from Liu Mengtie’s C# Getting Started Tutorial, thanks to Mr. Liu.