开发者

Why Dependency Injection is also called Inverstion of control (IOC) [duplicate]

开发者 https://www.devze.com 2023-03-20 16:37 出处:网络
This question already has answers here: Closed 11 years ago.开发者_运维百科 Possible Duplicate: Inversion of Control < Dependency Injection
This question already has answers here: Closed 11 years ago.开发者_运维百科

Possible Duplicate:

Inversion of Control < Dependency Injection

I know what dependency injection is but trying to understand why its also know as Inversion of Control.


Inversion of control is a principle and dependency injection is a technique. The distinction is subtle and most people refer to them interchangeably.


Basically it means that not the components itself are in control for looking up and instantiating their dependencies anymore.

The term Dependency Injection came up in Martin Fowlers great article on Inversion Of Control Containers and the Dependency Injection Pattern:

As a result I think we need a more specific name for this pattern. Inversion of Control is too generic a term, and thus people find it confusing. As a result with a lot of discussion with various IoC advocates we settled on the name Dependency Injection.

0

精彩评论

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

关注公众号