What is the IOC container

Original link: https: //www.cnblogs.com/boke1/p/11047260.html

1.IOC is not a technology, but an idea, an important rule of object-oriented programming that guides how we design a loosely coupled, better program. Traditional applications are created by our initiative within the class dependent objects, resulting in a high coupling between classes, it is difficult tests; Once you have the IOC container, create and find the dependent objects of control to the container by container implanting a combination of objects, between objects and the objects are loosely coupled, which would also facilitate the testing, which will help multiplexing function, more importantly, the overall architecture of the program is very flexible. At runtime, the container will depend on dynamic objects outside the injection assembly, when the outer container starts, it initializes the outer container. Create and manage bean object, and destroy him, this application itself is not responsible for the creation and maintenance of dependent objects, creation and maintenance of dependent objects called inversion of control is in charge of the outer container.

2.IOC (inversion control) and DI (dependency injection)

IOC (Inversion of Control, inversion control). This is the core of spring, throughout. The so-called IOC, for spring framework, it is the relationship between the spring be responsible for controlling the lifetime of the object and the object.

DI (dependency injection). IOC is a focus of the system is running, the dynamic of other objects you need to provide to an object. This is achieved by DI (Dependency Injection, dependency injection)

Guess you like

Origin www.cnblogs.com/imtudou/p/11910558.html