Rustysun classmate ASP Code writing specification _asp Foundation

Source: Internet
Author: User
Tags lowercase modifier reserved
Code for writing ASP source program
1 Specification Introduction
This code mainly stipulates the ASP source program in the writing process should follow the rules and precautions. The purpose of writing this specification is to keep the code writing habits of project developers consistent. This allows each team member to understand the other team's code, so that the two development of the source code memory system maintenance.
2 General format specification
2.1 Indent
Indentation is the two spaces that are exposed when the level of the source program changes to increase readability. The rules for indenting indent four spaces per level. You are not allowed to use tab. Because the tab will have different effects because the user makes a different setting (if you are accustomed to using spaces, you can set tab to four spaces in the editor). When entering judgment (if ...) Then, Select ... End Select), loop (for[each) ... Next, while ... Loop), with statements, functions, procedures, and class declarations, adds one level, and decreases one level when encountering exit judgments, loops, with statements, functions, procedures, classes. For example:

CODE:
Itemp=0

If (itemp<>) Then
ITEMP = 100
End If

2.2 Line Change
A newline is a newline that is added at the beginning and end of a judgment, loop, and with statement. When the declaration of a function, procedure, class ends, join one. The line-wrapping is for the program convenient debugging, the readability is stronger.
Example 1:



CODE:
I=0

Do while (I&LT;10)
i = i + 1
Loop

Response.Write (I & "<br/>")

Example 2:



CODE:
Class Class1
.....
End Class

Class Class2
....
End Class

Example 3:



CODE:
Function fun1 ()
....
End Function

Sub Sub1 ()
....
End Sub

2.3 Spaces
Add spaces at both ends of the operator and logical judgment symbol, for example:



CODE:
i = i + 1
A = A and b
SHTML = "abc" & SHTML

However, no spaces are required to add parentheses. For example:



CODE:
If (a > B) Then ' ERROR usage
If (a > B) Then ' correct usage

3 VBScript Grammar writing format specification
3.1 Reserved words
The reserved words or keywords in the VBScript language should all use the first letter capitalization and the remainder of the letter lowercase principle (recommended). In addition, you can use all lowercase, mainly for the convenience of input source program.
3.2 Procedures and functions
3.2.1 Nomenclature and format
The names of procedures and functions should all be made up of meaningful English words, and the first word is all lowercase, and the first letter of the other Word uses uppercase letters. If there is only one word, capitalize the first letter. For example:



CODE:
Sub formatharddisk () ' Incorrect naming
Sub Formatharddisk ' correct naming
Sub Show () ' incorrectly named
Sub Show () ' The right name '

Procedures and functions that set the contents of a variable should be prefixed with a set, for example:



CODE:
Sub Setusername

Procedures and functions that read the contents of a variable should be prefixed with a GET, for example:



CODE:
Function GetUserName

Parameters for 3.2.2 Procedures and functions
First, all parameter names must be meaningful. The name of the parameter is synonymous with English, several English words may be used, but the first letter of each word must be capitalized. First describe the reference type of the parameter, such as ByVal or ByRef. The parameter name is preceded by the prefix ' A_ ', followed by the type of the argument (see Writing specification in the variable type), must be lowercase, and the last word is capitalized with the parameter name and the first letter. For example:



CODE:
Sub Someproc (ByVal a_susername, ByVal a_iuserage)

3.3 Variables
3.3.1 variable naming and formatting
First of all variables must have a meaningful name, so that other members can easily read the meaning of variables, variable naming in synonymous English name, can use a few English words, but the first letter of each word must be capitalized. You also need to reflect the variable type in the variable name. For example:



CODE:
Dim Swriteformat ' s represents a variable of type string

3.3.2 Variable Type
Although you do not need to declare a variable type in an ASP, it has only one variant. But in order to facilitate the reading of the source program, we decided to prefix the variable with the type description. For some specific types you can use a certain shorthand as follows:
Variable type shorthand
Integral type (integer) i
Short integer (Shorter integer) sh
Long integer L
Single-precision (single) SN
Double db
byte type (byte) by
Character type (char) c
string s
Binary type (Binary) bn
Boolean (Boolean) b
Date-Time (datetime) d
Array A
Image Type (Object) o
loop control variables usually use a single word Furu: I, J, K. Another use of a meaningful name, such as Iuserindex, is also permissible.
3.3.3 Global Variables
Try not to use global variables, you must prefix ' gbl_ ' If you must use global variables, and you should reflect the type of the variable in the name of the variable.
3.3.4 Class-level variable (class Variables)
Class-level variables mainly refer to variables in class that work for all properties and methods within the entire class. It must be prefixed with ' cls_ ' and the type of the variable is reflected in the variable name.
For example: Cls_ifilename
3.4 Classes (Class)
The name of the class must be meaningful and prefixed with ' T ' before the name. For example:



CODE:
Class Tupload
...
End Class

The name of the class instance is usually to remove the ' T '. For example:



CODE:
Dim oupload:oupload=new Tupload

3.5 Forms (Form)
3.5.1 Naming Standard
Forms and table item names should be meaningful and prefixed with type shorthand. Type and shorthand for the following table:
Type shorthand
Forms (Form) frm
text box (textbox, including Password box and multiline text box) txt
check box (checkbox) chk
Radio Box (Radio) RDO
Buttons (button) btn
Drop-down box (Select) SLT
3.6 Files
3.6.1 directory Structure
Program Home directory--web (application path)
-DB (the path where the local database resides)
-doc (the path where the document resides)
-help (the path where the Help files are located)
-backup (Backup path)
-temp (temporary file path)
3.6.2 file naming
The file must use a meaningful name. For example: The system of a user data entry form of the file named Frmadduser.asp, to the database input user information file name is adduser.asp.
3.6.3 File Header
The head of all files should be written on the purpose of this file, author, last modified date, use. For example:



CODE:
‘/**
' *@ Author: cjj
' *@ use: Upload file
' *@ Date Created: 2006-11-29
' *@ Revision history:
' * CJJ (modifier) modified in 2006-11-30 (modified date) in order to solve ... (change instructions).
' * ZS modified in 2007-1-1 to solve ....
‘........
‘*/

4 Modification Specification
The provisions of these rules apply only to programs that have been incorporated into configuration management. In such modifications, it is required to retain the content before the modification and to identify the changes and additions. and add the necessary information such as modifying person, modification date, modification explanation in the file header.
4.1 Modifying history
When an approved modification is made to the source file, the modifier should include the Modify history entry in the program file header. For each subsequent modification, the modifier must fill in the following information in the project:
4.2 New lines of code
There should be a comment line description before and after the new line of code.



CODE:
' (* CJJ (modified person) 2006-10-11 (modification Time) .... (Change note)
... ' (New line of code)
' CJJ 2006-10-11 *)

4.3 Deleting lines of code
Delete lines of code before and after using the comment line description.



CODE:
' (* Modified description of modification time modified by the person)
' Line of code to delete (comment on the statement that will be deleted)
' Modification Time Modification end *

4.4 Modifying lines of code
Modify the line of code to delete the line of code in the new line of code.



CODE:
' (* Modified description of modification time modified by the person)
' Line of code before modification (comment out the line of code before modification)
Modified line of code)
' Modification Time Modification end *
Related Article

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.