1. IOC and DI
Ioc:inversion of Control This is a very big concept.
The call of the object which is traditionally manipulated directly by the program code is given to the container, which realizes the Assembly and management of the object component through the container. The so-called "inversion of Control" concept is the transfer of control over a Component object, from the program code itself to the external container.
Di:dependency Injection
An IOC approach to implementation.
2. IOC and DI contact
3. Di's understanding
DI: Dependency Injection.
Relies on calls between-----classes (objects).
Here are a few questions to consider:
Question: Why is dependency generated?
Layered design concepts (should be familiar with web development): Easy to develop and maintain.
Dao--------->daoimpl--------->servie
The Daoimpl implementation Dao,service layer can use Daoimpl to manipulate the entity, rather than directly implementing DAO to manipulate the entity.
Question: How do I generate Daoimpl objects in the service layer?
Scenario One: Direct new, disadvantages: memory consumption and life cycle is not easy to control;
Scenario Two: Provided by the container. Advantages: With the use of the follow-up, do not consider the life cycle of control.
Issue: How to provide objects by container:
Dependency Injection.
Implementation: Configuration in an XML file.
Add:
IOC and DI