IOC container and dependency injection mode

Source: Internet
Author: User
Summary

Martin Fowler's classicArticle+ Transparent and brilliant translation + 1-2-3 UML illustrations (this is not enough to concern your teeth, huh, huh ).

Download Original Text

IOC container and dependency injection mode Martin Fowler, transparent translation, PDF format.
Good English friends can also read the original article inversion of control containers and the dependency injection pattern.

UML illustration

I drew UML diagrams for constructing subinjection, setting value injection, interface injection, and service locator. I wanted to insert them directly into the PDF file, but I thought this would affect the quality of the original text, after thinking twice, I decided to paste the image into the blog.

Use picocontainer to construct subinjection (page 5)
The yellow color class in the figure is a component written by Fowler and cannot be changed by his friends. The green color class can be added/modified by his friends.
The movielister and moviefinder class layers constitute the Strategy Mode. Movielister complies with the design principles for interface programming. Another good thing is that the client class movielistertester does not depend on the Implementation class (such as colonmoviefinder ). Dependencies on implementation classes are encapsulated in the configurecontainer () function.

Use spring for Value Setting Method injection (page 6)
The yellow color class in the figure is a component written by Fowler and cannot be changed by his friends. The green color class can be added/modified by his friends.
The movielister and moviefinder class layers constitute the Strategy Mode. Movielister complies with the design principles for interface programming. Another good thing is that the client class movielistertester does not depend on the Implementation class (such as colonmoviefinder ). Dependencies on implementation classes are encapsulated in a file called "Spring. xml.

Interface injection (page 7)
The yellow color class in the figure is a component written by Fowler and cannot be changed by his friends. The green color class can be added/modified by his friends.
The movielister and moviefinder class layers constitute the Strategy Mode. Movielister complies with the design principles for interface programming.
Note that although the colonmoviefinder instance is created in the ifacetester # configurelister () function, because only the injectfilename () function of injectfilename of the narrow interface is used, so there is still the potential to make ifacetester only dependent on the injectfilename interface.

Use service locator (page 8)

Sequence Chart

Toolbox

The UML diagram is drawn using the Visio 2003 + Pavel Hruby's uml2.0 template. The text part is typed using Google Pinyin input method.

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.