Building Asp_net Logical Component Library
Profile
Use asp.net to develop highly reusable, loosely coupled, well framed Web applications. And can form a highly available component library.
Object
This article is mainly for the use of ASP. NET develops BS system developers, project managers, and leadership in charge of software quality.
Background and the way to solve it
Background, the characteristics of the application software: 1, the value of business, business complex, a lot of unique customer requirements, many versions, some companies for each customer to produce a new version, very few people understand the differences between all versions, so many versions of the company's heavy burden, 2, product function coupling is serious, function is difficult to reuse, 3, Software modification task is heavy, perhaps this is the most frustrating, a project after the development, customers continue to make changes, many developers in the long-term into the change task. These characteristics and problems make the company development department like Snowball roll the bigger and heavier, the workload is more and more heavy.
Way to solve the problem:
For the above problems, application software development can solve the problem using the following methods:
1, the extraction component, enhances the reuse.
2, interface change skin, easy to modify, the interface is changeable.
3, the script passes the parameter, avoids the coupling.
Content
Framework: Includes page, component library, data component library, data component factory four parts. The page is responsible for the overall appearance of the site and loading the component library, the component library provides the logical function, the Data component library provides the business data, the data component factory is responsible for generating the data object. These four parts can be summed up as two library two ties. The page is the link between the component library and the user, and the data component factory is the link of component library and data component.
1, page
The page is responsible for the overall appearance of the site and loads the widget library.
Page is the overall UI performance of the site, the main work is the picture production, page cutting, loading components, and to pass parameters to the component, and responsible for site navigation.
Division of Labor: Art and skilled HTML personnel development.
2. Component Library
This is the core of the framework, and we use the user control to easily and quickly complete these 3 points:
1, the extraction component, enhances the reuse.
2, interface change skin, easy to modify, the interface is changeable.
3, the script passes the parameter, avoids the coupling.
1. Extract artifacts to improve reuse.
The processing of a certain logic functions packaged into user control, which is easy, mainly how to reuse, generally we are mainly in the same project using user control, but only across the project to achieve reuse, in fact, Codebihand technology is an inheritance relationship, the user interface inherits from class library, So the user control's class library is referenced to the project, and the user control's ascx code is placed in the directory under the project, and it can be like using a user control in the same project.
In addition, if you need to debug, you can put the source code into the user control directory to track debugging.
2. Interface change skin, easy to modify, the interface is changeable.
The interface of the user control is easily modified, which also has a deep understanding of Codebihand technology, where multiple ascx files (control UI code) can correspond to the same CS file (Control class code). We also need to do this, for example:
This is a login widget, the function is to accept user input, authenticate users, return login information, if successful, guide other pages. After this widget is finished, we find that we also need a login widget that can be placed on the navigation bar, which we have 3 choices, 1, new one, duplicate code, code reuse, but the code repetition brings the problem is quite troublesome. 2, the extension widget function, through a parameter to decide how to display. This has a problem, to modify the program, is the program becomes complex, and the use of code control display often in the later maintenance stage is very troublesome, the need to modify the program, 3, make a set of skin, the programmer relaxed, the code does not change, and the skin can be easily modified, maintenance is easy
This is the landing widget on the navigation bar.
It's a good idea to have these 2 UI parts correspond to the same CS code.
This is not very well supported in Microsoft Visual Studio. NET 2003 Development tools, and it does not have a good organization for this code, and it appears that the CS code for one of the controls seems to be missing. As shown in figure:
The Gcon_linellogin.ascx code does not look relevant, but it does not affect use.
Maybe Microsoft didn't think of it, but we did need to use it, and it was affordable.
Division of Labor: Software engineers in the detailed design, functional division, and the development of components, may not be very beautiful, then, art can take away the skin of the component, the production of many sets of different skin components. But the component's coding is only one, thus realizes the component diversification, and avoids many versions the generation.
3, the script passes the parameter, avoids the coupling.
The use of controls necessarily involves interacting with other controls and pages. For most user controls, it is not very complex to interact with pages and other user controls, such as the login control above, which simply needs to know that the page is displayed when the login is successful, and that it is necessary to use scripting to pass parameters for this simple interaction, to write code in the page instead of using Codebihand technology The code written on the page is easier to change, reducing the strong coupling.
Let's take a look at how to write script code:
Through analysis, found that the page part and Codebihand code is inherited in the relationship. So we can overload the OnInit () method. In the page development execution is to join our operation. By passing parameters in this way, it is convenient to change the value of this parameter at any time, and the program does not need to be compiled.
Wrong way, in the user control directly decide which page to import, without leaving parameters, the user control because of this small move, completely lose the flexibility, also lost the possibility of reuse.
Additional:
The flexible usage of user components,
ASP.net user component is very large, user component is a server component, it has the advantages of server-side components, and the development of convenient, very suitable for the needs of application software developers.
To use user artifacts, you need to know the following:
1, a deep understanding of codebehind, it brings more than just like the development of win-form programs to develop applications.
2, try to add attributes, events, methods to user artifacts. Fully expand and understand the functionality of user artifacts.
3, trying to get the user widget to inherit a custom interface, the interface is very powerful and we have to use it.
4, dynamically loading user artifacts. Multiple user artifacts on the same page can all be dynamically loaded.
5, loading user artifacts in another DLL, which can reuse user artifacts and build the foundation of our own component libraries.
6, so that the artist to a good compilation of user space to protect the different skin (edit ascx HTML code can), can be found because of the change of ascx code, user components will have a variety of faces, forming a variety of interface series.
7, does not change the page of the CS code to the user component transfer parameters, so you can implement the component and the page loose coupling, the page add, reduce components, pass parameters, all do not compile the program.
Summarize:
Use C # to develop business components and component factories, which have not been written here for the time being, the ASP.net component library and the Business Framework Library can unify the quality development process, including the Division of Art and programmer, form the art material storehouse and so on, accumulate the company's resources.