DI in the Development

Source: Internet
Author: User

Author: czy

 

Di pattern (dependency injection) frees us from the sophisticated construction of the depended objects.

In the business view, it helps the developers concentrate on the business domain without any worries on the initialization of the depended objects.

In the architecture view, it facilitates the reuse of the component as the depended objects are resolved in the Di.

 

Let's take the design of teamview as an example.

There is a jiraimportcontrol to import the Jira system output XML to the teamview. The UML dimo-goes as following.

From the digoal, we can see the dependency between createdbform and jiraimportcontrol is quite neat.

We can easily move jiraimportcontrol to another container without much more coding than let the di construct jiraimportcontrol in that container.

However, if we give up Di, let's see what hell wocould be.

Without the Di's help, the additional dependencies come up to us. I admit that the some additional dependencies in the dimo-wocould be a little overstated. however, if we want to resue the jiraimportcontrol in another container, we have to take dbconnection construction and define construction (God bless that itemimporterimpl wowould have no dependencies) into consideration. if the other container can't supply the necessary parameters to the constructions, the design of container itself must be changed. so, the hell appears that changes happen over the system just to satisfy a little change in a little corner.

 

There are using perfect di framework, we use autofac as the Di.

Additionally, please go to our website novasoftware for more information about the team.

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.