What is Inversion of Control?

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

    Inversion of control is when you go to the grocery store and your wife gives you the list of products to buy.

    In programming terms, she passed a callback function getProductList() to the function you are executing - doShopping().

    It allows user of the function to define some parts of it, making it more flexible.

提交回复
热议问题