What is Inversion of Control?

前端 未结 30 2838
清歌不尽
清歌不尽 2020-11-22 00:13

Inversion of Control (IoC) can be quite confusing when it is first encountered.

  1. What is it?
  2. Which problem does it solve?
  3. When is it appropria
30条回答
  •  悲哀的现实
    2020-11-22 00:20

    A very simple written explanation can be found here

    http://binstock.blogspot.in/2008/01/excellent-explanation-of-dependency.html

    It says -

    "Any nontrivial application is made up of two or more classes that collaborate with each other to perform some business logic. Traditionally, each object is responsible for obtaining its own references to the objects it collaborates with (its dependencies). When applying DI, the objects are given their dependencies at creation time by some external entity that coordinates each object in the system. In other words, dependencies are injected into objects."

提交回复
热议问题