Control inversion and Dependency injection

Source: Internet
Author: User
Tags abstract

On the web, these concepts seem complex and controversial. I read a few of these articles and summarize them according to my own comprehension. Where study, must have the note output, otherwise equal to never learned.

In fact, the inversion of dependency in control inversion (IoC), Dependency Injection (DI), and design patterns is same strain: a representation of interface-oriented programming.

The principle of dependency inversion:

A. High-level modules should not be dependent on low levels of modules, they should all rely on abstraction.
B. Abstractions should not be dependent on specifics, but should be dependent on abstraction.

Second, control reversal:

A direct dependency between two objects becomes a common dependency on the interface.

This is the reverse; control, originally two objects are coupled very deep, control each other.

Iii. Dependency Injection:

Inside an object A, another object B is used. This depends very deeply. Switch

Inside object A, an interface or abstract function is used, and object B inherits from that interface or abstract function. During the run, the object B is then passed as a parameter to the inside of object A (injected, I am, good yellow good violence).


In these several concepts are closely related to the interface.


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.