Object-oriented programming and comparison

xiaoxiao2021-03-06  41

ASP is Microsoft's dynamic web programming technology that Microsoft launched, but it combines ADO to easily and easily quickly and easily, combined with XML, COM / ActiveX, etc. To achieve server multi-layer structure, which makes it in today's tenacious vitality. And still have a certain development. ASP.NET although it is completely different from ASP on the architecture, many built-in objects are also expanded based on ASP. There are countless articles on the Internet, which has been introducing the ASP object-oriented and compared with other languages. This is why I am determined to write this article. Because it is an early version, the ASP only provides a weak object-oriented interface. As is well known, the implementation of the ASP is divided into VBScript and JavaScript / JScript: there is a Class keyword in VBScript, which can be used to declare a custom class; JavaScript is quirky, it uses a function to "declare", then in this function The attribute is defined by this.Prototype, this.func definition method. Here will be discussed as VBScript, and the class declaration of VBScript is like this:

Class name                                                                                                                                          Regarding the attribute, I have to praise Microsoft's GET and SET methods. This is the concept that occurs in COM. It is always used in .NET, I personally think that PutProp (), setprop () two more than Java Methods to achieve the same effect, it is necessary to easily and intuitive. In contrast, the classes in VBScript and the classes in the PHP4 have thousands of autumn (of course to the latest PHP5 can't be better), and the classes in VBScript maintain the "characteristics" of the incomplete object-to-object object of VB, which only implements the most Basic construction / destructor, member functions, variables, attributes, and even constructor cannot with parameters. In the PHP4, the importance of inheritance, function overload, etc., and only these can be called object-oriented, and it is possible to provide a basis for achieving polymorphism. But both have no functionality such as static members. Although you can use other changes to achieve the same effect, this is not thorough (because PHP is very flexible, PHP4 can indirectly realize static variables through the static variables of the member function; :: "- You can realize the operator of the class static function - there is no strict check in PHP4. In other words, all member functions can be accessed as a static function, as long as you do not use the member variable in this function. Will not go wrong. Vbscript does not implement static at all, only SESSION or Application is implemented). So in the usual use, you can use the VBScript custom class to encapsulate some operations, but don't expect it to be object-oriented ideological services like C / Java / .Net. VBScript also carries forward the default parameters or variables in VBs are referenced. This way, although the Script language is not sensitive to the type, it can reach the C / C pointer / reference equivalent, complete a lot of things. The most basic, such as use it defines a list (List) node list listNode:

<% Class listnode sub copition_initialize () content = "node" set nextnode = Nothing end.com is so simple, but don't feel embarrassed, don't forget the initial value of the variable. VB is also almost similar, and the type is added when the declaration is declared. When used:

<% Set nh = new listNode NH.NEXTNODE = new listNode 'other statement ...' traversal list set n = nhwhile not n is nothing response.write n.content
"SET n = n.nextnode%>

If you don't add other code, the result of the above is two "node". VBScript's custom class and objects are not outside, as long as you master the basic concepts, you have a certain understanding of it, just simply. Again emphasizing that the SET statement is used to assign the object, which is equivalent to the assignment in Java, is a reference. This is more than the default object assignment to the copy constructor to create a new object (even obj = new obj; such a statement creates two objects! If you want to get a reference, you want to change the variable after the equal number Plus & Before you appear, it seems that PHP5 does not want to modify this practice of php4. The session itself in theASP is to store objects, which can save basic variables, arrays, automated objects, etc., but encounter problems when saving custom class objects. As of the following code:

<% IF ISEMPTY ("Node")) The set session ("node") = new listNodeet n = session ("node") response.write n.content%>

Or the above listNode, this code is intended to hold only one ListNode object in a user session. So when the user visits the web page, generates an object of ListNode and saves in the session ("Node"); when the webpage is accessed, because the session ("node" is not empty, it will not Generate a new object, but to the SESSION ("Node") to remove the saved object. Theoretically, 100 should also be output, but the problem is coming, the ASP will always report the error:

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

New Post(0)