Understanding the need for a DI framework

前端 未结 12 1793
长情又很酷
长情又很酷 2020-12-07 12:39

This might be a naive question. I\'m currently learning the Spring framework and dependency injection. While the basic principle of DI is rather easy to grasp, it\'s

12条回答
  •  萌比男神i
    2020-12-07 13:12

    Dependency injection is a degenerate form of implicit parameter passing, and the purpose is essentially the same, to solve what's called The Configurations Problem:

    The configurations problem is to propagate run-time preferences throughout a program, allowing multiple concurrent configuration sets to coexist safely under statically guaranteed separation.

    Dependency Injection frameworks compensate for the lack of implicit parameters, Curried functions, and convenient facilities for monads in the language.

提交回复
热议问题