Dependency Injection Summary

Source: Internet
Author: User

First, dependency injection is basically three ways:

1, the first is the setter injection, it can be understood to assign a value to the property of the interface type in the customer class, call different service types according to the actual type of the property, which may use the policy mode;

2, through the constructor for the client class interface type attribute assignment, according to the actual type of the property call different service types;

3, through configurable to set the dynamic invocation of different service types, that is, dependency acquisition, which may be used in the abstract factory;

In fact, the above three are used in OO polymorphism, so you have to use dependency injection, which eliminates the duplication of code, and in line with the OCP principle, although may sometimes be more code, but improved maintainability, hierarchical structure is also clear.

About dependency Injection a better piece of blog post share: http://www.cnblogs.com/leoo2sk/archive/2009/06/17/1504693.html

Dependency Injection Summary

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.