Specification requirements for ASP development

Source: Internet
Author: User
Tags constant function definition lowercase trim backup

In order to standardize program code writing, improve the readability of the code, reduce maintenance costs, improve office efficiency, the proposed program in the following several specifications:

First, the Unified VBScript and ASP program writing specifications:

(i) Variable naming rules:

Since it is not necessary to declare variables in ASP and VBScript, and not to declare the types of variables, in order to improve the readability of the code and develop a good development habit, the uniform Rules for variable naming for this system are as follows:

1. Use Dim, public, private declaration variables;

For example: Dim istudentnum

2. Expression of variable type:

A, Integer variable: Start with the lowercase letter I, followed by the variable designator, the first letter of the English word capitalized.

For example: The following declares a variable that stores the database record

Dim Iresordsetnumber

b, single-precision entity variables: Starting with the lowercase letter F, followed by the variable designator, the first letter of the English word capitalized.

C, double entity variable: Beginning with lowercase d, followed by variable designator, the first letter of the English word should be capitalized.

D, character variables: The beginning of the lowercase letter s;

E, Boolean variables: beginning with lowercase b;

F, array variables: Array type + "_" + "Array" + "_" + "Variable indicator"

For example, define an array that stores student scores (stored single-precision entity type variables)

Dim F_array_studentmark

3. The variable designator should conform to the Mark Standard, and it is easy to understand, try to use English words instead, try to avoid using abbreviation or shorthand.

For example, the string variable that stores the alumni Address Book is defined as:

Dim sschoolfellowaddresslist;

Although this definition is troublesome in the input, it greatly improves the readability of the program, which is known by its variable naming. It is also more convenient when making variable lookup. Speed and performance are not always the same, in order to facilitate the latter we will only sacrifice speed.

4. A comment that adds a variable function definition after a variable definition.

(ii) constant naming rules:

The type shows the same as above, and the difference is that all subsequent identifiers are capitalized, for example:

Defines a character type constant for a storage language type:

Const slanguage_type= "Chinese"

(iii) Functional functions, process naming rules:

1. Use function declaration functions, use sub Declaration procedure;

2. The first letter of the function name or procedure name is capitalized, and the first letter of each subsequent word is capitalized.

For example:

Function Checkvalidityofinput (Sstuentmark)

' Write code here

............

End Function

3. Function name or procedure name to be easy to read, simple and clear.

4. In front of the function of the comment, explain function function, parameter description, creation date, modification date, change reason, creator, modify person and so on related information.

(iv) Code indentation criteria:

In order to improve the beauty and readability of the code, this paper presents the layout format of the code: interval and interval are spaced at one time.

For example:

‘***********************************************************

' function: detects single quotes in the input string, and if so, turns one single quotation mark into two

' single quotes, two to four, and so on to avoid SQL statement execution errors.

' Creator: XXXX

' Creation time: 2002-7-6

' Modify Time:

' Cause of change:

' Modify Person:

' Input parameter Description: sinputstring: String that needs to be checked in single quotes

‘***********************************************************

Function Checkvalidityofinput (sinputstring)

Dim Icirculationcontrol ' control loop

Dim sapartstring ' split character detection

Dim ilenofinput ' input character length

Ilen= Len (Trim (sinputstring))

For Icirculationcontrol = 1 to Ilen

If Mid (sinputstring, Icirculationcontrol, 1) <> "'" Then

Sapartstring = sapartstring & _

Mid (Trim (sinputstring), Icirculationcontrol, 1)

Else

sapartstring = sapartstring & "" "

End If

Next

Checkvalidityofinput = sapartstring

End Function

Second, unified JavaScript Program writing specification:

The naming rules for JavaScript are the same as most of them, except that the variables are declared with Var, ending with a semicolon (;) after the declaration ends.

The code requirements of the function are clear, it should be written in the next line as far as possible to write down, do not complete all the code in a row, so it seems difficult to check the error is particularly time-consuming.

When writing functions, remember to annotate the content, so that you can quickly understand the function of the program after maintenance.

The following is a JavaScript program:

Third, the system can improve code specification:

1. In the ASP page, the objects (Com, Recordset, etc.) that are created using creageobject () should be released at the end of the page:

Set object variable name =nothing

2. When the database is open, when not in use (usually the last side of this page), the connection needs to be closed;

3. For SQL statements, stored procedures, try to avoid using * to take all the fields, for the readability of the code, the SQL keyword requires all uppercase, the field part lowercase.

For example:

SELECT name,age,birthday,telephone,address from schoolfellow.address WHERE name= ' xxxx ' ORDER by birthday DESC

4. All attribute values in the ASP page are enclosed in double quotes, especially those with attribute value, and do not remove the double quotes because of the time saved (some places can be removed, the program will not be wrong, but, in some places to remove double quotes will lead to more trouble.) )

For example:

">

In this example, if you remove the single quotation mark from the Value property, if the value in the database has a space and the value is followed by a space, the result is that the contents of the display are just the contents of the space, and the contents of the following are lost. That's just one of those things, and there's a lot of other unknowns going on.

5. Pairing label problem: for like labels, pay attention to check the matching bit value, there is no end sign.

6. If you need to enter a string and need to use an SQL statement, you need to do a single quote, call/include/ Checkq.asp two methods (one is client processing, one is server-side processing, call as needed, the security requirements in most cases using server-side processing. One

7. In order to improve security, can use the code written by ASP, as far as possible using ASP writing, running on the server side, do not allow users to see the code.

8. For a particularly high security requirements, the proposed three-tier structure: the use of VB or Delphi to write business Logic Layer Code (COM), as far as possible to the database connection part of the package into components, improve security performance, through the components and database Exchange.

9. For the safety of the website, should use good fracture scanning software, view the site has opened the fracture, the unsafe fracture to close.

Iv. develop the habit of writing and developing documents:

For each page design (front page, back page), including function description, page design, page name, storage location, etc., should have corresponding documentation. For changes, you need to keep the original part (note or backup), and indicate where the backup file is stored, the time of the change, and the person who modified it.

For the program section, there should be a corresponding design process, changes, also need to design changes to the flowchart, in order to compare later, and find the location of the problem, as well as the severity of the problem analysis.

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.