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

前端 未结 2 622
野的像风
野的像风 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 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

提交回复
热议问题