Inversion Of Control vs Dependency Injection with selected quotes – is my understanding correct?

前端 未结 2 611
野的像风
野的像风 2020-12-25 08:21

I\'ve read a number of threads explaining the difference between IoC and DI and while many of explanations contradicted each other, I think

相关标签:
2条回答
  • 2020-12-25 08:56

    I have written the differences at my [blog]:http://dotnet-stuff.com/tutorials/dependency-injection/dependency-inversion-principle-dependency-injection-and-inversion-of-control-dip-ioc-and-di "click here for updates" that how can we organize Inversion of Control, Dependency inversion Principle & Dependency Injection. In brief we can say that--

    At the top is Dependency inversion Principle which is a way of designing software. It doesn’t say how to make independent module. Inversion of Control(IoC) provides the way of applying DPI principle. But still IoC doesn’t provide us specific implementation. It gives some methods so that we can invert the control. If we want to invert control using Binding inversion or dependency creation then we can achieve it by implementing dependency injection (DI).

    0 讨论(0)
  • 2020-12-25 09:05

    Well this is my point of view:

    DI Overview

    DIP means that you program against an abstraction. You invert the kind of a dependency from an implementation to an abstraction.

    IOC means that somebody else is responsible for getting the implementation for the given abstraction. Normally the consumer would use the new keyword to get a dependency. With IoC you invert the control, so that the consumer is not responsible for creating the instance anymore.

    Dependency Injection and Service Location are a part of Inversion of Control. DIvsSL

    See also: https://stackoverflow.com/a/10053413/175399

    0 讨论(0)
提交回复
热议问题