A case study of Component Object Development Web application

Source: Internet
Author: User
Tags count manual query client
Reprint of the Computer World)
Xia Changhong Dongliang Chen Wenbo
A Analysis and development of application examples

----We have developed a set of application system based on the idea of Windows DNA, which is the background of student status management system. In this system, the transaction logic of the academic school is all handled by the custom COM component, and the Dynamic Web page calls these components through ASP script. The system is better than the ASP script in terms of development speed and software quality. To illustrate the problem, we simply introduce the implementation of local functionality through a custom component and the main code for ASP scripts.

----in the Displayscore.asp page to accept, identify the user's query request, make a different query processing. When the identity of the customer as a teacher or the Senate, you can inquire about the results of all students, when the identity of the customer as a student, can only query the student's own results.

----Custom COM component Score.dll for query processing. First design the interface of the component, set four properties for the component: SUBJ (Course), Term (Course semester), Class (query Class) and Stu_no (query student number); Define two methods: Requeryscores and Requeryallscores, The teacher, the Academic Administration department and the student's request makes the corresponding processing, and returns the query result set to the user.

----The following are some of the key code to implement the Score.dll of this component. From here we can see how the interface of the component is implemented:

Option Explicit
Private M_stuno as Variant
Private M_SUBJ as String
Private M_term as String
Private M_class as String
' Set property to writable
Public Property Let Stuno (ByVal Vnewvalue as Variant)
M_stuno = Vnewvalue
End Property
Public Property Let Subj (ByVal Vnewvalue as Variant)
M_SUBJ = Vnewvalue
End Property
......
' Students query performance request processing
Public Function requeryscores () as Object
Dim Objcontext as Mtxas.objectcontext
Set objcontext = GetObjectContext ()
' Establish transactional components
Dim objconn as ADODB. Connection
' Accessing the database with ADO
Dim objRecordSet as ADODB. Recordset
Set objconn = New ADODB. Connection
objConn.Open "Xia", "sa", "" "
Set objRecordSet = New ADODB. Recordset
Dim Query as String
' Based on query requirements (all courses are queried, all courses for a particular semester are queried,
Query for a specific course, for a course in a particular semester, for different query operations
If (m_subj = "All" and M_term <> "all") Then
query= "Select Client_name,client.client_no,courses.subject,
Stu_score.score,stu_score.term,sub_type "
query = query & "from Client,stu_score,courses"
query=query& "where client.client_no=stu_score.client_no
and Stu_score.subject=courses.subject
and Courses.term=stu_score.term
and Courses.term= ' "& M_term &" '
and client.client_no= ' "& M_stuno &" "
End If
......
Objrecordset.open Query, objconn
' Make a database query
Objcontext.setcomplte
' If the transaction completes successfully, the transaction is committed
Requeryscoresexit:
Set requeryscores = objRecordSet
' Returns the query result set
Exit Function
Requeryscoreserr:
Set requeryscores=nothing
' Transaction failure handling
End Function
' Teachers, academic inquiry results request processing
Public Function requeryallscores () as Object
......
End Function
----reference the component in the ASP page displayscore.asp, the ASP code is as follows (where the bold part is the call to the component):
<%@ language= "VBSCRIPT"% >
< HTML >
< head >
< META name= "generator" content= "Microsoft
Visual InterDev 1.0 ">
< META http-equiv= "Content-type"
Content= "text/html; Charset=gb_2312-80 ">
< TITLE >show to teacher</title >
< body background= "IMAGES/BK. GIF ">
<%
Dim Objresult
Set Objresult=server.createobject ("Display.score")
Dim term,subject
Term=cstr (Request.Form ("Term"))
Subject=cstr (Request.Form ("Subject"))
Objresult.term=request.form ("term")
Objresult.subj=requestform ("Subject")
Objresult.class=request.form ("Class")
Dim Scores
Set Scores=objresult.requeryallscores
% >
' The following code shows the results of the processing
< div align= "center" >< Center >
......
< table border= "0" cellpadding= "0"
cellspacing= "1" width= "M" >< tr >
<%for I = 0 to scores.fields.count-1% >
< TD bgcolor= "#004080" >
< strong >< font color= "#FFFFFF" > < small >
<%=scores (I). Name% ></font > </strong > </td >
<%next
Do while (not scores.eof)% >
</tr >< TR >
<% for I = 0 to scores.fields.count-1% >
< TD bgcolor= "#ACE8F9" >< P align= "center" >
<%= Scores (I). value% ></td >
<%next
scores.movenext% ></tr >
<%loop% >
<%scores.close
' Close the database connection
Set scores=nothing
Set Objresult=nothing% >
' Release object
</table ></center ></div >
</body >
----can imagine that if you use ASP script only for business processing, the code in the ASP page is very bloated and obscure. And the solution using the component is also faster than the simple ASP script execution speed. And the whole query can be treated as a transaction to ensure the security and integrity of the database information. Registering the component in MTS also avoids network congestion that may result from multiple users accessing the home page. In practical applications, students and teachers have different rights to use. In the page where the student queries the results, you can reuse the component and simply invoke its different interfaces. Only using ASP scripts for business processing, you need to rewrite the same cumbersome code that is similar to displayscore.asp. In the development process, different developers can dens, simultaneously carry on the design of the Component and ASP page, shorten the software development cycle.
----The following two figure shows the teacher (Dean) query results and the page showing the result of the query:

Two Use of assistive tools in the development process

----Traditional software engineering needs analysis, database design and so on are people "pure manual" completed, lack of rigor and normative. In the process of component-centric system analysis and software development, we should strive to use effective computer aid tools to adapt to the new situation of rapid modeling and component method, and improve the quality and accuracy of the analysis.

----have a lot of assistive tools to take advantage of. As the component-centric system analysis process still retains the thread traces of traditional software engineering methods, the case tool of Beida Bluebird is more effective than traditional software engineering methods, and we adopt this tool. In the aspect of database modeling, we choose Sybase Company's S-designer, which can transform the database concept model into physical model automatically.

----1. Using Bluebird Case tool to write requirements analysis documents

----For a long time, people have been accustomed to "pure hand" to conduct demand analysis. When a developer investigates the existing system and user requirements, it is necessary to design the system's Data Flow Diagram (DFD), write a small description, and design the system's structure (SC) diagram. But this method of analysis is not rigorous, due to a variety of reasons, may occur processing, data flow, file syntax definition errors, the different layers of data flows inconsistent with the flow diagram decomposition of the information, or file names and documents such as incomplete, and other problems, affecting our user needs analysis and understanding, Hinder the work of the future. In particular, the analysis of the components of improper, disastrous consequences.

----Bluebird Case tool is a set of tools to support software engineering using traditional structured methods for demand analysis and software design. Each file that is generated by the tool is a project, and each project includes a data flow diagram and a module structure diagram:

The data Flow diagram assists the system analyst to complete the requirement analysis of the software system, establish the demand model of the target system, generate a correct and complete instruction document about the target system, and provide the analysis function of the query, list, fragment and influence scope of the requirement document. The Assistant software designer analyzes and understands the result documents of the requirement analysis, so as to facilitate the software design work.

The module Structure Diagram Assistant Program designer designs the software system after the requirement analysis stage, supports the layer refinement of the module, builds the software architecture of the system, and finally obtains a correct and complete software design document. At the same time, it provides the analysis function of query, list, fragment, influence range and so on, completes the design result document thorough, the detailed analysis understanding, is advantageous to the software development and the maintenance work. In the SC diagram the components of the planning scheme have been seen, continue to refine will be drawn to each component of the schematic design scheme.
----in the case of the educational administration system, the DFD and SC diagrams generated by the Bluebird cases tool are shown in the following illustration:
----System 1-layer DFD diagram System 0-layer SC diagram

----2. Using S-designer to design database

----When the detailed design of the system is completed, the following is the database design. Database design plays an important role in the whole software engineering. The database design is unreasonable, the data is not reasonable and effective storage, the data exists latent inconsistency, incompleteness or have a lot of redundancy, will reduce the system performance, even make the system crash.

----Manual database design depends entirely on the design level of the designer. The designer must first establish a number of logically existing database tables based on the actual needs and make them meet the third normal form, and then link them to a specific database table based on the relationship between them. This is a rather cumbersome matter. The Database Designer should not only make the logical design of the database, but also turn the logic model into the physical model, and the designed database may not satisfy the third normal form. The Reasonable library table structure determines the design quality of the interface, so the original database design method is not suitable for the software design with the Component object as the center.

----in the case of the teaching system, S-designer makes the database design easy and easy. The designer only needs to be realistic design the E-R diagram of the database, S-designer will convert the logical model into physical model, establish a new table for the relation between the database tables, indicate the main code and the Code of the table, and automatically check the database table for consistency, redundancy and integrality, so that the database table satisfies the third normal form.

----Example: You can first design a database table course (courses) and a student (Client) logical model:

----Next, establish a link between the table courses and the client. The physical model automatically generated by S-designer, as shown in the following illustration, provides an accurate basis for the interface design of the visiting component.

----can believe that with the further development of software engineering, more computer-aided tools will emerge to help software developers build more sophisticated application systems. Many assistive software tools can do similar work, depending on the performance of these tools and the user's habits.

----Dynamic Web methods and DNA ideas centered on component objects are not inscrutable, and development techniques are becoming more standardized. It should be said that this approach is more suitable for the objective information structure of the reality, but also closer to the way people think, its technology is like flowing natural, very suitable for small and medium enterprises to promote and popularize the environment.

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.