IOC = inversion of control di = dependency Injection

Source: Internet
Author: User
What is IOC = inversion of control and dependency injection )?

Beginners who are new to these concepts are confused. Just as I saw these terms for the first time, I was embarrassed ...... The IT industry is eye-catching, and every new vocabulary is so awesome. Fortunately, we also have the Internet, the most extensive source of information.

IOC is controlled by containers.ProgramBetween, rather than traditional implementation, by the programCodeDirect control. This is the concept of "control reversal": control is transferred from application code to external containers, and control is transferred.
When the industry is clamoring for IOC, the master Martin Fowler also spoke up to post a classic articleArticle"Inversion of control containers and the dependency injection pattern" is the name of IOC. So far, IOC has a new name: "dependency injection )".

Compared with IOC, "dependency injection" is indeed a more accurate description of this ancient and fashionable design concept. According to the name, dependency injection is the dependency between components determined by the runtime of the container. In the image, the container dynamically injects a dependency into the component.

A simple example: one IBM T40 laptop, one USB hard disk, and one USB flash disk. A laptop is connected to a peripheral storage device through a pre-specified interface (USB). For a laptop, only user-specified data is sent to the USB interface, it is determined by the USB device currently connected. Before the USB device is loaded, it is impossible for the notebook to predict which device the user will connect to on the USB interface. Only after the USB device is connected will the dependency between the devices begin to form.

according to the preceding description about the dependency injection mechanism, the runtime (system boot, USB device loading) is performed by the container (Windows operating system running in the notebook) inject dependencies (laptops rely on USB devices for data access) into components (Windows File Access Components ).
This is a version of the dependency injection mode in the real world.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.