What is Inversion of Control?

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

    But I think you have to be very careful with it. If you will overuse this pattern, you will make very complicated design and even more complicated code.

    Like in this example with TextEditor: if you have only one SpellChecker maybe it is not really necessary to use IoC ? Unless you need to write unit tests or something ...

    Anyway: be reasonable. Design pattern are good practices but not Bible to be preached. Do not stick it everywhere.

提交回复
热议问题