开发者

Do we achieve Dependency Inversion Principle using Dependency Injection technique?

开发者 https://www.devze.com 2023-02-24 11:28 出处:网络
开发者_运维知识库Do we achieve Dependency Inversion Principle using Dependency Injection technique?

开发者_运维知识库Do we achieve Dependency Inversion Principle using Dependency Injection technique?

Am I correct?


Yes. Dependency inversion says “do not seek your dependencies yourself, they will be supplied to you.” Dependency injection is a way of supplying the dependencies to the object from the outside.


yes it is

The Dependency Inversion Principle in two sentences:

High level modules should not depend upon low level modules. Both should depend upon abstractions.

and

Abstractions should not depend upon details. Details should depend upon abstractions.

while

The Dependency Injection Pattern is one of the concrete solutions to the application/code composition problem. And yes this solution is implementation of the Dependency Inversion Principle. Probably the most known place to read is Martin Fowler - Inversion of Control Containers and the Dependency Injection pattern.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号