IoC control inversion and ioc Inversion

Source: Internet
Author: User

IoC control inversion and ioc Inversion

Ioc control inversion involves two concepts: 1, control 2, and reversal.

Control: What do you want to control? A: control of the create object, that is, control of the specific implementation class of an interface.

Reversal: Who is the initial control? Who should the control be handed over? A: Generally, the new object is directly used in the call class, so the initial control is the call class. Then, the control is handed over to a third party for decision.


IoC is not open enough, so it has been widely discussed in the industry. Finally, Martin Fowler, a senior in the software field, proposed the concept of DI (Dependency Injection: Dependency Injection) to replace IoC.

DI dependency injection: This allows the call class to inject the dependency between the implementation class of an interface by a third party (container or collaboration class) to remove the dependency of the call class on an interface implementation class.

(Container or collaboration class) such as bean container in spring:

<? Xml version = "1.0" encoding = "UTF-8"?> <Beans xmlns = "http://www.springframework.org/schema/beans" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: p = "http://www.springframework.org/schema/p" xsi: schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id = "Interface class" class = "implementation class"/> <bean id = "call class ID" class = "call class" p: interface Class-ref = "Interface Class"/> </beans>

 

Related Article

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.