Reference | specification | Development specification
ASP Development Specification-write this thing please advise, later development good less to eat a bit of pain.
One, one-page writing specifications:
Remember that the page needs to be divided into modules:
First module: Receive parameters. [It is possible to submit from different pages to the same page, or you can see which of the two form items is treated as a priority.
Second module: Define global variables.
The third module: Write processing code (as much as possible to include the code in the function, see page Note one.) )。 --Complete the main part of this ASP code.
Module four: Pure HTML code that uses the values stored in global variables to generate pages.
Five (note): To write the page logic on the head of the page. (How to receive and process.) )
Advantages: Easy to maintain. The module is self-contained and facilitates reuse to similar pages.
Second, the whole station file construction specification:
1. After the project took over, watch the static page, grasp the logic and the order of navigation.
2. Extract the site to be reused to make embedded files.
3. Extract the header file, the tail file, and the left menu bar, made into embedded files.
4. Divide the page structure, make the template file. --Copy it later in production, and then it can be directly produced.
Note: Don't be in a hurry to write a page, unless you're taking on a small project, or the user's needs are very clearly defined and won't change, otherwise, it's important to keep the page code readable! (How are you feeling when you face the big rework?) Consider the potential danger first! )
-Because each of us understands the code we write, it's harder to read the code that someone else writes. And, due to changes in customer demand, it is more common to modify or even overthrow the original design. So pay attention to write code when the attention of the latter to quickly read, and easy to modify. [It is necessary to add a note to the head of the page, in an important part of the code, as well as some explanatory comments.] ]
All we do is just to: increase portability, make logic clear, facilitate maintenance,
Adapt to changes in user needs, and complete as soon as possible, reduce the effort.
――――――――――――――――――――――――――――――――――――――
Note I: The third module prepares a description. ASP page Authoring Structure
1. Write notes First
2. Write embedded file.
3. Write large chunks of ASP code (removed from COM)
--Note: complex pages, try to encapsulate different COM operations in separate functions;
--there is a call at the end of the function, the data that is processed by the function directly in the following page (has been assigned to the global variable)
--to validate the validity of the page entry parameters before calling the function.
Note II: Note Fourth module preparation. Part of the HTML code that needs attention
1 It is best not to make the page's ASP code and HTML code mixed together,-feel more confusing.
2 Obtain the data of the global variable to get the processing result of ASP.
3 About client javascript:
Verify the validity of the form before submitting it. Written in
To the dropdown box to have and hide the button synchronization, write out a separate small function, placed under the button.
For large innerHTML-type client interaction, write the code in the corresponding
Write client script, you can write more functions, so that the parameters passed between functions, simple, so that there will be similar pages in the future, can be removed and then used.
Requirements for Web page production:
Web page personnel to complete the page, in order to ensure that there will be no confusion in use, please do the following processing:
1. Do not nest too many forms;
2. The width of the table should be defined by pixel width;
3. Single page, a function module to make a table, in order to write the page, the duplicate part of the extracted into the embedded file.
4. Other note: Thin code, note the width of characters and borders in the table.
5. Name in English lowercase plus digit (and half-width underline). [Think about the horrors of your page moving to UNIX hosts]
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
' 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 and end with a semicolon (;) at the end of the declaration.
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.