Object-Oriented ASP Technology: Thinking and Practice

zhaozj2021-02-16  51

table of Contents:

Overview

history

Advanced technology and easy-to-use technology: ASP

At the end? Component Web

program

An instance

Tips

Overview

This paper briefly describes the history of Web development, and mainly compares JSP, ASP, and ASP.NET. Finally, a conceptual model is made more detailed and make a simple implementation. This model will enable the simple and easy-to-use technology of ASP to become a high choice for SMEs or small and medium-sized project development. This article is suitable for the advanced developers of the ASP.

history

Today's web applications are increasingly popular, and software based on B / S structures has also increased. This is not difficult to imagine, as SUN President Scott said, "computer is network", with the development of Internet technology, knowledge is adequately spread around the world. Since the 1990s, the original static HTML page (now you can see the HTML3.2 book in the old bookstore, with 16-bit Internet Explorer or Netscape Navigator illustration, then the webpage of the web page is no longer comparable to it now), To complicated and lack of customized CGI, then the rise of Windownt, there is something called IDC, IDA, IDQ (of course, now those things have not existed, but the author is still in the same year, but now I can't remember anything), then I am based on VBScript ASP2.0. This is, Java gradually invades the Internet programming field, servlet, JSP has also appeared. Other, such as PHP, Perl, etc.

There are so many techniques, both ASP, JSP or PHP, etc., in the early days, their programming model is nothing more than the following mode: the client submits an HTTP / GET or HTTP / POST request to the server, the server get this After the request, the database is requested to respond to the client directly to the client directly. That is, a simple "request-response" model. The only advantage of this model is simple. With the emergence of large web applications, this model is so fast. For example, it is unable to implement the code (in the web development, the redundant code seems to be difficult to avoid), and many pages have similar functions and similar code. When the demand changes, the change changes so inconvenient. So people are very annoyed. Unable to achieve complex business logic, simple structure determines that this model cannot be competent. Waiting, such as the problem, so that the seniors of Web development began considering more effective patterns.

At this time, it is worth mentioning that JSP Model2 is a very common mode in the SmallTalk language: Model-View-Controller. Introduced related professional articles about this model, here is not described again. All in all, this model has changed the concept of most web developers, allowing them to consider B / S software with a software structure, rather than the original "stream development". Apache Struts in MVC mode is achieved, which has become a new technique for developers and accepted technology. (For JSP and servlet, please see another article I translated: "Servlet and JSP, Best Practice")

The launch of ASP.NET can be said to be a progress. Code-behind technology and page callback, etc., no matter how efficient, single from these technology itself, and raise our web development concepts. The server HTML component can be interacting with the C # code, and so natural, she has to admire Microsoft's structure. Now let's talk about the theme of this article: ASP.

Advanced technology and easy-to-use technology

Currently in the web development field, there are almost no one to optimize ASP. There are always someone complaining about the ASP developers on 9CBS. And the ASP does exist like such a problem, the biggest problem is that it is a non-compilation script, all scripts are executed by explaining, which makes his efficiency greatly discount. In addition, its weak type variable defines the difficulty of learning learning and his efficiency. Various problems show, give up ASP, don't pursue a falling technology.

However, I don't think there is an experienced web developer who will say, ASP is not easy, ASP is not easy to learn. Nowadays, there are many ASP experts, but JSP, ASP.NET master is difficult to cultivate. In the JSP version of 9CBS, ask "How to configure the JSP Run Environment" is not in a minority, and some other "character encoding", "database connection", etc. In the ASP species, it is indeed uncommon in JSP. Here I am inadvertently compare the ASP and JSP, I don't dare to attack JSP or say a bad thing to JSP. From the perspective of pure technology, I think that on ease of use, the ASP will be slightly wins, and in the grasp of small and medium-sized projects, the vanity of individual or technical circles will be greatly grasped than JSP. If the reader is a multi-year experience and knowing the ASP and JSP, it should not be opposed to my point of view.

However, the advantages of JSP are all. From the height of the software structure, it is too good. With JavaBean technology and expansion tag library technology, the concept of JSP has far exceeded itself. Component is easy, high efficiency, convenient expansion, easy to achieve multi-layer structure, and so on.

From now on the trend of the Web development (or the trend of the entire software), the idea of ​​componentization is increasingly important. The problem now is that the basic ASP function is clearly unable to meet the growing and complex demand, how to implement component thinking in ASP?

About Components We can think of the most direct way is to use VisualBasic or Visualc or any other Windows environment programming tool. Then, almost everyone will say: VC development components are the highest efficiency, but very slow; VB development formula is the fastest, efficient is also good. Indeed, VB has easy access to COM, COM , and so on, and the development speed is fast and the debugging is convenient. In this way, VB is the first choice for developing ASP components. Another thing that has to be mentioned is XML. There are a lot of benefits to using XML, and there is not much more here.

My basic idea is: use VB to write components, configure applications with XML. The concept of the components here is no longer the functional component of the past (for example, SafileUpload, Jmail, etc., just to implement a component implemented in a function. This type of component is currently occupied by most ASP server components market.) More, more is to implement an entity (entity). That is, in the object-oriented ASP technology, the presence of two components: functional components and entity components.

Functional components are mainly used to implement one or a set of functions. Of course, these functions should also be together with object-oriented ideology. For example, a functional component called LoginControl contains the following methods: Checklogin, Updatelogin, Loginout, etc., more common examples are database operations. You can write a database to a component method to call on the ASP page. The entity assembly only implements basic objects and its properties and methods. Examples of the most common application are more than User components, which may have Name, Account, Password, etc. Attributes. The most prominent benefits using user components is to make full use of cheap resource-memory to store logically independent complex objects, reducing the use of expensive resources (such as database links). The XML role is to provide a simple configuration of the application, and establish a loose contact between the ASP page and the component. With this connection, the app can divide, disassemble and assemble with a very casual and easy way. This idea comes from the current Struts-Config.xml and the web.config in the ASP.NET in MVC Struts.

Registration of VB components has always been a big problem. The current web application has far exceeded the concept of past. It turns out to be a website, but now you can do a complex application system, but not only on the virtual host running in the ISP, more and more applications are deployed to the enterprise's internal network. In this case, the registration of components in VB is not a problem. Generally, unless necessary, use a DLL in one project. Of course, debugging in the development process may be very boring. At the end of this article, there are some components debugging tips. If you really plan to use this way to develop web applications, you can refer to it.

Here is an actual example. Due to the time, the environment, the author operates and tests the code on its own machine. Due to the limit, the author does not provide the entire sample code (if the reader is familiar with the ASP and VB, the code is very Simple), the following example is just a simple development prototype. More factors are required in the actual system usage.

Example of a member registration, login, and logout:

The following example uses the object-oriented idea mentioned above. In this small example, the following parts are included:

User class is used to simulate an entity in the application system

DataProvider class provides all database operations

Globals class read configuration XML file

(The above class is encapsulated into ExtendPortal.dll.)

Some related ASP files

Assume that our site name is ExtendPortal

1. Define XML files (App-config.xml)

extendal

AccessDB

DSN = EP

Top is just an example, you can define in the actual project.

The class diagram is as follows:

(figure 1)

The processing flow of the system is as follows:

According to the above figure, a completed web development project can organize and build in a high structure, and in the model of the entire system, it is reflected in the object-oriented idea, and this model is used. The connection between multilayer structural modules is loose, divided into workers, and organizations are very easy. Of course, the biggest "disadvantage" of this model is to spend more time to analyze the needs of the user in the initial period, and thereby analyzes the corresponding entity components and functional components. However, this seems to be the general characteristics of all normal operation projects.

Development skills

At this point, the reader should have a certain understanding of this model proposed by the author. However, there is also a need to pay attention to many problems in the actual development, and the biggest problem is more debugging. Re-registration each time you recompile the component, or even you have to restart. Some of the tips below may be able to help you reduce these troubles:

1 Careful programming! Don't let the compiler help you find those simple errors, such as variables are undefined, the function is wrong, etc. These errors often occupy most of the time.

2 Select a suitable thread model. Don't compile your components with a single thread, think you can think.

3 By setting "high" in the process environment of the web program, then you can re-register the components by uninstalling the application without restarting IIS.

Conclusion:

This article discusses a new ASP programming model that is different from the general COM components, and the concept of entity components is proposed. I hope this article can help small and medium-sized projects or developers who use ASPs to reduce development risks or developers with a higher level of help.

转载请注明原文地址:https://www.9cbs.com/read-19699.html

New Post(0)