What is Inversion of Control?

前端 未结 30 2871
清歌不尽
清歌不尽 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:19

    Using IoC you are not new'ing up your objects. Your IoC container will do that and manage the lifetime of them.

    It solves the problem of having to manually change every instantiation of one type of object to another.

    It is appropriate when you have functionality that may change in the future or that may be different depending on the environment or configuration used in.

提交回复
热议问题