Written in front of the words:
Everyone who writes a program knows that when you gradually expand the functionality you are about to implement, very big time, the first day of writing things forgot to write there, a lot of time, have to write detailed program development notes, this in the ASP's system development, especially when the file, function complex, When we intend to modify some of the functions of the site, feel no way or feel to change the place. At this time, if you have learned any object-oriented programming language, naturally think of how to implement the Code function module, ASP is not in essence object-oriented programming, but VBSCRPIT6.0 provides classes, we can implement the code through the encapsulation, implementation module words.
First of all, I want to write some very official concepts here to illustrate that object-oriented is very concrete, very solid mode, not to let some people see "object" is scared away.
Objects are things you can see, feel, hear, touch, taste, or smell, and here we are. "Definition": an object is a self-contained entity that is identified by a set of identifiable attributes and behaviors.
In object-oriented programming (OOP), use the following two terms.
Class: This is the template for the object, which defines the attributes of the object.
Example: This is a real object that can interact with it.
Properties, methods, and events
In OOP, the following terms describe the attributes of an object:
Attribute: This is a ranking that describes the properties of an object.
Method: This is a verb that describes the work that an object can accomplish, or the work it is expected to accomplish.
Events: Describes the actions that an object performs for a corresponding action.
In programming, objects are part of object-oriented programming and object-oriented design, they have great advantages, many people think this is a complex topic, but in fact, it is very simple, can be explained in four simple terms: abstraction, encapsulation, polymorphism and inheritance.
Abstract: This is a hidden complexity, the internal workings of the class, so the user does not have to know how it works, just like. If you want to watch TV, you don't have to know how to work the TV, just turn on the TV, search the channel, the On/off switch abstracts the actual operation, in the string example, there is a trim method, it can delete the string trailing spaces, also do not need to know how he completed the task, Just know that it has this function.
Encapsulation: Each object contains all the information that is required for the operation, which is called encapsulation, so that the object does not perform its own operation more than relying on other objects, and in the term ToUpper () method, a string does not have to get information elsewhere to convert all characters to uppercase.
Polymorphism: This term is used to indicate that different objects can perform the same actions, but by their own implementation code to execute, the name is the same, but the underlying implementation of the code is not the same.
Inheritance: It defines how classes relate to each other, share attributes, inheritance works by defining classes and subclasses in which subclasses inherit all the attributes of the parent class, and the importance of inheritance is that it forces a class of similar types to be consistent and allows sharing of code, and if you decide to create a new class, you do not have to define all the attributes of the parent class.
Using classes in ASP to achieve modularity
Let me take a few simple examples to illustrate, note that here is an emphasis on the idea that it is necessary (and difficult) to expand an ASP site with a class (base class).
Let's first choose a simple example:
We want to display the information of the Classic forum users, when you enter the user ID can, display some information about the user, this is a process, you can consider this, we regard the user as an object, he has attributes are ID, gender, integration, permissions, the implementation of the method has to display this information, OK, so write:
Class blueidea
Private bname,bpoint,bsex,blevel
''''...................
end class