Difference between creating new object and dependency injection

后端 未结 6 2268
粉色の甜心
粉色の甜心 2020-12-08 01:24

What is the difference between creating a new object and dependency injection? Please explain in detail.

6条回答
  •  不思量自难忘°
    2020-12-08 01:47

    When using an inversion-of-control container to perform dependency injection, the container creates the objects, and not the developer. This is done so that the container can "inject" these objects into other objects.

提交回复
热议问题