Rustysun ASP code writing specifications

Source: Internet
Author: User

ASP source code writing Specification
1. Specification Overview
This specification mainly specifies the rules and precautions that ASP source programs should follow during the writing process. The purpose of writing this specification is to make the source code writing habits of project developers consistent. In this way, every member can understand the code of other members, so as to facilitate the maintenance of the secondary development and Memory System of the source code.
2. General format specification
2.1 indent
Indentation is two spaces that increase readability when the source program changes. The indentation rule contains four spaces for each level of indentation. Tab is not allowed. Because tabs have different effects due to different settings (if you are used to spaces, you can change the Tab to four spaces in the editor ). When determining (If... Then, Select... End Select), loop (For [Each]… Next, While... Loop), With statement, function, process, class declaration to add a level, when the exit judgment, Loop, with statement, function, process, class is reduced by a level. For example:

CODE:
ITemp = 0

If (iTemp <& gt; 100) Then
ITemp = 100
End If

2.2 line feed
A line feed is added to each of the start and end times of the judgment, loop, and With statements. When the Declaration of functions, procedures, and classes ends, add one. Line breaks are used to facilitate program debugging and improve readability.
Example 1:

CODE:
I = 0

Do While (I <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 operators and logical judgment symbols, for example:

CODE:
I = I + 1
A = a And B
SHTML = "abc" & sHTML

But no space is required when brackets are added. For example:

CODE:
If (a> B) then' incorrect usage
If (a> B) then' correct usage

3 VBScript syntax writing format specification
3.1 Reserved Words
The reserved words or keywords in VBScript should all use the first letter in upper case and the other letters in lower case (recommended ). In addition, you can use all lowercase letters to facilitate the input of the source program.
3.2 process and Function
3.2.1 name and format
The process and function names should all consist of meaningful English words, and the first word is all in lowercase, and the first letter of other words uses uppercase letters. If there is only one word, the first letter is capitalized. For example:

CODE:
The Sub formatharddisk () 'is incorrectly named.
Sub formatHardDisk 'is named correctly
The Sub show () 'is incorrectly named.
Sub Show () 'is named correctly

Set should be used as the prefix to set the process and function of variable content. For example:

CODE:
Sub setUserName

The process and function used to read variable content should use get as the prefix, for example:

CODE:
Function getUserName

3.2.2 process and function parameters
First, all parameter names must be meaningful. The parameter name is in synonymous English. You can use several English words, 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 must be prefixed with 'a _ ', followed by the parameter type (see the writing rules in the variable type). It must be in lower case, followed by the parameter name, and the first letter of the word must be in upper case. For example:

CODE:
Sub someProc (ByVal a_sUserName, ByVal a_iUserAge)

3.3 Variables
3.3.1 variable naming and format
First, all variables must have meaningful names, so that other Members can easily understand the meaning of the variables. Variable names use synonymous English names and can contain several English words, however, the first letter of each word must be capitalized. In addition, the variable type must be reflected in the variable name. For example:

CODE:
Dim sWriteFormat's indicates a String type variable

3.3.2 variable type
Although the variable type does not need to be declared in ASP, it only has one Variant type. However, to facilitate the reading of the source program, we decided to add the type description prefix to the variable. Some specific types can be abbreviated as follows:
Abbreviated variable type
Integer (Integer) I
Short Integer sh
Long Integer (Long Integer) l
Single precision type (Single) sn
Double db
Byte
Character type (Char) c
String type (String) s
Binary type (Binary) bn
Boolean B
DateTime type d
Array type (Array)
Object o
Cyclic control variables generally use single characters such as I, j, and k. It is also allowed to use a meaningful name, such as iUserIndex.
3.3.3 Global Variables)
Do not use global variables as much as possible. If you must use global variables, you must add the prefix 'gbl _ 'and reflect the type of the variables in the variable name.
3.3.4 Class Variables)
Class variables mainly refer to the variables that work for all the attributes and methods within the Class. The prefix 'cls _ 'must be added for use, and the variable type must be reflected in the variable name.
Example: cls_iFileName
Class)
The class name must be meaningful and prefixed with 'T '. For example:

CODE:
Class TUpload
...
End Class

The class instance name is usually removed from 'T '. For example:

CODE:
Dim oUpload: oUpload = new TUpload

3.5 Form)
3.5.1 naming standards
The naming of forms and form items should be meaningful and use the abbreviated type as the prefix. Types and Abbreviations:
Abbreviated type
Form (Form) frm
Text Box (TextBox, including password box and multiline text box) txt
Check box (CheckBox) chk
Single-sector (Radio) rdo
Button btn
Select slt
3.6 files
3.6.1 directory structure
Main Program directory-Web (path of the Application)
-DB (path of the local database)
-Doc (document path)
-Help (path of the Help File)
-Backup (Backup path)
-Temp (temporary file path)
3.6.2 file name
The file must use a meaningful name. For example, the file name of a user data input form in the system is frmAddUser. asp, and the file name of the user data input to the database is addUser. asp.
3.6.3 File Header
The purpose, author, and last modification date and purpose of this document should be written in the header of all files. For example:

CODE:
'/**
'* @ Author: cjj
'* @ Purpose: upload a file
'* @ Creation date: 2006-11-29
'* @ Modify history:
'* Cjj (modifier) modified on (modification date) to solve ..... (Modify description ).
'* Zs was modified on to solve the problem ....
'........
'*/

4. Modify specifications
The rules only apply to programs that have been included in configuration management. In such changes, you must retain the content before the changes and identify the changes and new content. Add necessary information such as the modifier, modification date, and modification description to the file header.
4.1 modify history
When the source file is modified with approval, the modifier should add the modification history item in the program file header. For each subsequent modification, the modifier must fill in the following information in the project:
4.2 Add code lines
Comments should be added before and after code lines.

CODE:
'(* Cjj (modifier) 2006-10-11 (modification time ).... (Change description)
...... '(New code line)
'Cjj 2006-10-11 *)

4.3 Delete Code lines
Comment the line before and after deleting the code line.

CODE:
'(* Description of the modifier's modification time
'Code line to be deleted (comment the statement to be deleted)
'Modifier modification time modification ended *)

4.4 modify code lines
Modify the code line to delete the code line and then add the new code line.

CODE:
'(* Description of the modifier's modification time
'Code line before modification (comment out the code line before modification)
Modified code lines)
'Modifier modification time modification ended *)

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.