IOC, DI, and MVC in Spring.net

Source: Internet
Author: User

Overview

Spring.net is an open-source business layer of the framework, the function is very powerful, due to the 3 features: aspect-oriented programming, IOC and DI, provide comprehensive framework support, this blog mainly talk about the IOC and DI, and its provided support for the MVC framework.

IOC and Di

IoC, English full name inversion of control, inversion of controls, DI, English full name Dependency injection, Dependency injection. In short, the IOC is the object that is created, and Di is the initialization when the object is created.

The IOC and DI are equivalent to the abstract Factory + reflection that we usually write, but are more powerful than the abstract factory, but the idea is the same, decoupling. We realize the decoupling between the upper and lower layers through the abstract Factory + reflection, of course, which has the corresponding middle layer (interface) to provide the corresponding type assurance of the lower layer, And Spring.net provides the IOC and DI is also implemented, but, we use the spring.net framework, we do not need to write the corresponding abstract factory, do not need to maintain this class, spring.net has already encapsulated me as the corresponding DLL component, we just need to reference the corresponding component, and then make the appropriate configuration file for the configuration to be a matter of this feature.

provides support for the MVC framework

The MVC framework can be said to be a framework of the UI layer, the function of the control class is to accept the request, return the data, its processing of the data business logic to the BLL layer (business logic layer) processing, we through the spring.net provided by the DLL component to achieve the separation of the U layer and B layer.

For the UI layer is not the MVC framework class, we introduce the corresponding DLL, after the corresponding configuration file configuration, we will create a container object, and then give its corresponding key to the container object to get the object we want, this way is for the UI layer without schema, And for a program that uses the MVC architecture in the UI layer, we implement it in a different way, as outlined in the overview above, Spring.net provides support for a comprehensive framework, so we can know that Spring.net also provides the appropriate DLLs to interface with the MVC framework, which is specific to the process: define the corresponding property (IBLL interface type) in the control class, and then Configuration file configuration, implementation, of course, when accessing the control class, the corresponding properties are initialized.

processing of configuration files

using the Spring.net framework, we will write a lot of content in the configuration file, if the content is only written in a Web. config, it will be very messy, at this time, we can create the corresponding XML file, the corresponding configuration, of course, this needs to be configured appropriately, if we use such a party , we need to be aware that we are going to do some processing of the XML file's properties and get it to the UI layer, because our program accesses the configuration file based on layer I.

Summary

We do a program that we use Spring.net + M (easyui) VC + ef/nhibernate + T4 This framework, and a program that does not use layering and any architecture compared to the performance, certainly the latter is highly efficient, because the code executes less processes, the path is short, so, Very fast, but why is the architecture of the upper, and many people think that this architecture is very good?

To know the above answer, we need to analyze why there are two cases above, why? Because we do the types of programs, for the Internet system, the requirements of the system is the speed of execution, for the enterprise-class business system (oa\erp\ management system, etc.), the requirements for the system is the change of demand can be flexible response,OK, so we are clear, Why there are so many frameworks, and there are still a lot of people who are committed to the development of frameworks, as well as the reasons for the corresponding optimization work.

From the above analysis we can know, for the program, not to use the framework is good, not without the frame is not good, but to the right use.

IOC, DI, and MVC in Spring.net

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.