IOC Inversion of Control

IOC Inversion of Control

IOC (Inversion Of Control) Inversion of Control . It is an important principle of object-oriented programming, which is used to reduce the coupling problem between computer programs .

Inversion of control is divided into two types
1. One is DI (Dependency Injection) Dependency Injection
2. The other is DL (Dependency Lookup) Dependency Lookup.

Dependency injection is used more in practical applications.

Description: A simple understanding of inversion of control means that in a java application, the use of objects has changed from the way we actively new an object to the way that we create and provide by spring, and we passively receive it. That is, the creation and management right of the object is created by the programmer -> transferred to spring to create -> the programmer passively receives and uses the object.

simply put

  • It turns out: When we get the object, we all use the new method. It is an active way to create.

image

  • Now:
    When we get an object, we ask the factory at the same time, and the factory finds or creates the object for us. in a passive way.

image

The idea of ​​acquiring objects in this passive way is inversion of control

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325624533&siteId=291194637