Web programmer coding specification (ASP)

Source: Internet
Author: User
Tags case statement coding standards html indent custom name
I. Page Design
1. IMG Control
ALT: all display images must have a text description that briefly describes the image content.
2. input control
Maxlength: Specifies the maxlength attribute for all input controls. The default value is the length of the corresponding field in the database.
Readonly: The readonly attribute must be used for all unchangeable information.
3. Form Control
Action: action must be specified for all forms. If submitted to itself, Action = "" is specified ""
Method: Use post to perform irreversible actions, and use get to perform reversible actions.
Onsubmit: All forms must specify the check programs required before submission.
All forms must have corresponding reset buttons.
4. Button Control
Onclick: the button used for submission in form does not allow this method. All data checks are activated through form's onsubmit.
5. Title attributes
All pages must have the same title as this page.
6. Control naming
Use the control type abbreviation (lower case) + English word (the first letter in upper case.
Controls in Development basically involve several types
Button: BTN
Form: FRM
Select: Sel
Textarea: txt
Input: IPT
7. Language settings
Add the following statement to all Chinese pages:


8. Control attribute assignment
The attribute values of all controls must be enclosed in double quotation marks or single quotation marks.

Ii. Client Program
1. Handling of error message (2-1)
All error messages are displayed in Chinese. punctuation marks are used as follows:
"Error:" + prompt message + "! "
2. Processing of successful prompts (2-2)
All successful messages are displayed in Chinese. punctuation marks are in the following format:
"Success:" + prompt message + "! "
3. Page return
Use history. Back () when returning the previous page; do not use history. Go (-1 );
Use history. Go (-N) when you need to return the first n pages (n> 1 );
All responses are connected instead of buttons.
4. Data judgment before submission
Make sure that the data before submission is determined by the Javascript data type and length.
Digit or not: Use the isnan () function ()
Length determination: determine the actual length after removing Spaces
Empty: All input fields that are not allowed to be empty must be judged after spaces are removed. If this field is a query condition, it must not be blank.
If a data error is found in the judgment condition, the system prompts the error message through (2-1), and then focuses the error field through the method focus.
5. Prompt before data deletion
All operations involving deletion must be confirmed after the user is selected.

Iii. server-side programs
1. Data Acquisition
The data transmitted through the get and post connections must be removed through trim before and after the data is used.
2. Data judgment
The parameter data obtained through the request must be determined again by null, type, and length.
3. Close the object
All Database and file objects should be closed as early as possible after use, and nothing should be assigned at the same time.
4. Prompt information
All error messages are prompted using JavaScript to ensure that the user does not see any internal error messages. (For example, 1-1)
A prompt is required for successful operations involving database update, Del, and insert. (For example, 1-2)
5. Use of Variables
All variables must be declared before use, and the initial value is assigned.
6. variable naming
The variable type abbreviation (lower case) + English word (the first letter in upper case) is used.
Variables in development basically involve several types
Integer: I
Decimal: F
Character: S
Boolean: B
Date: d
Special:
I, j, m, n are used in sequence in the cycle;
Array with ary
Pointer p, q
Temporary Variable TMP

VII. SQL statements
1. Sort
When order is used, try to sort the fields that create indexes or primary keys in advance.
2. Select
Avoid using * When selecting. Even if all fields are required, list them one by one in the order they are used.
3. Avoid using in and not in whenever possible

8. Test
All pages must run at 800*600,102 4*768 resolution.
All pages must run in ie5.0, 5.5, and 6.0 without JavaScript errors.

**************************************** ************************

Web coding Specification
Prepared by: walaqi

Chapter 1 ASP coding specifications
ASP encoding consists of two parts: static file encoding and dynamic file encoding containing server scripts.
Static file encoding consists of script encoding and HTML encoding.
Server-side encoding is divided into three parts: server script, client script, and HTML Script.
The encoding rules adopt the following conventions:
All client scripts use JavaScript
All server scripts use VBscript
HTML scripts are used for static page output.
This specification does not apply to client script code generated by server scripts.

Chapter 2 static file encoding specifications:
The static file script is written in JavaScript. The output part adopts the HTML markup language.
1. html markup language coding Specification
1.1 line feed specification for marking:
* A tag must occupy one row. Do not mark two rows with the same mark (except for the mark with the same mark), for example:

Text


It must be written as follows:
Text



1.2 mark closing rules
* The static file content must be included in the tag.
* The tag must be included in the tag.
* For tags to be closed, such:
  

<Br/> <SELECT> <br/> <option> <br/> the flag must appear at the same time as the flag. For example, <br/>... <P> ........... </P> <p> ..... <Br/> * do not contain cross-contained statements, such as: <p> ..... </P> <p> <br/> 1.3 attribute assignment specification <br/> for tags that accept attributes, the attribute values must be enclosed by double quotation marks or single quotation marks. For example: <br/> 1.4 indentation specification <br/> * top-level parent tags are written in the left-aligned top lattice mode. <Br/> * The Next Level mark is written in the left-aligned and right-indented form of a tab. <br/> the next level is as follows, <br/> * the first character of the same level mark must be aligned up and down. <Br/> 2. client JavaScript specification <br/> 2.1 variable naming convention <br/> * constants and global variable names must all use uppercase letters <br/> * the first letter of the variable name must be lowercase. <Br/> * The variable name must start with a string of its type. Various types of written strings are as follows: <br/> * integer variable: int <br/> * long integer variable: LNG <br/> * floating point variable: flt <br/> * double-precision variable: DBL <br/> * object reference variable: OBJ <br/> * string variable: Str <br/> * date type variable: DTM <br/> * variable names must be named with meaningful words, such as: <br/> strusername, lngarrayindex <br/> * variable names, except lowercase letters, other words must start with uppercase letters <br/> * If the variable name is too long, you can use the abbreviations, except for the widely known abbreviations, all variable names written using words must be annotated during definition, for example: <br/> var stradname // indicates the name of the Administrator account <br/> var stradminname // without comments, admin is widely known <br/> 2.2 variable usage rules <Br/> * variables must be defined before use. Undefined variables cannot be used <br/> * The use of variables should be minimized to a small scope. For example, use <br/> for (VAR I = 0; I </P> <p >}< br/> instead of: <br/> var I; <br/> for (I = 0; I </P> <p >}< br/> 2.3 object naming conventions <br/> The following prefixes must be used when naming various page objects, such as text input boxes, buttons, and drop-down selection boxes.: <br/> * text input box: TXT <br/> * button: BTN <br/> * select drop-down box: sel <br/> * option: opt <br/> * Form: FRM <br/> * frame: FRA <br/> * hidden form item: HDN <br/> * Div Tag: div <br/> * span flag: Span <br/> * dialog box object: DLG <br/> * window object: win <br/> 2.4 naming conventions for functions and sub-procedures <br/> * function names must be used Verb + noun pair method, and can reflect the function functions <br/> * the verb prefix of the function name must be a complete verb related to the function <br/> * the first letter of the function name is lowercase, uppercase letters of each word </P> <p> Chapter 3 dynamic file encoding specifications <br/> 1. HTML writing specifications <br/> HTML writing specifications must comply with HTML marking writing specifications for static files. For details, see section 1 of chapter 2. <br/> 2. client script specification <br/> dynamic file client scripts are all written in JavaScript and must comply with the JavaScript code specification in static file encoding specifications (refer to Section 2 of Chapter 2) <br/> 3. server-side script writing specifications <br/> server-side script writing adopts VBScript writing <br/> 3.1 naming conventions <br/> 3.1.1 VBScript variable naming conventions <br/> * constants and the global variables must all use uppercase letters <br/> * constants are required. You must use the const _ prefix <br/> * The global variable must use the G _ prefix <br/> * the first letter of the variable name must be in lowercase. <Br/> * The variable name must start with a string of its type. Various types of written strings are as follows: <br/> * integer variable: int <br/> * long integer variable: LNG <br/> * floating point variable: flt <br/> * double-precision variable: DBL <br/> * object reference variable: OBJ <br/> * string variable: Str <br/> * date type variable: DTM <br/> * variable names must be named with meaningful words, such as: <br/> strusername, lngarrayindex <br/> * variable names, except lowercase letters, other words must start with uppercase letters <br/> * If the variable name is too long, you can use the abbreviations, except for the widely known abbreviations, all variable names written using words must be annotated during definition, for example, <br/> dim stradname 'indicates the name of the Administrator account <br/> dim stradminname' does not need to be annotated, admin is widely known <br/> 3.1. 2 object naming conventions <br/> various objects such as connection, recordset, and command must use the following prefix during naming: <br/> * connection object: conn <br/> * recordset object: RS <br/> * command object: CMD <br/> * parameter object: Param <br/> * Field object: operator <br/> * error object: Err <br/> 3.1.3 function and sub-process naming rules <br/> * function naming must use a verb + noun pair, and can reflect the function <br/> * the verb prefix of the function name must be a complete verb related to the function <br/> * the first letter of the first word in the function name is capitalized, <br/> 3.1.4 naming rules for common variables: <br/> Description: The parts included in [] are omitted. <br/> * connection Object: conn [name]. Name is the name of the server connected to the database <br/> * recordset variable naming convention: Rs [name]. Name is a custom combination of English words related to the RS storage content <br/> * command object: cmd [name]. Name is a custom combination of English words related to command purposes <br/> * SQL statement string variable: strsql [commandname]. Commandname is a custom combination of English words related to the SQL statement function. For example: <br/> strsqlupdatemodify <br/> strsqlinsertuser <br/> 3.2 code writing specifications <br/> 3.2.1 explicit declaration principles of variables <br/> * All ASP program files, must be included in the first line of the Code. Convert to variable explicit declaration mode <br/> 3.2.2 Character Set setting principles <br/> * All ASP program files that generate Chinese output to the client, charset must be set to "gb2312" before output ". for example: response. charset = "gb2312" <br/> 3.2.3 function usage principles <br/> * use function encapsulation code blocks as much as possible <br/> * do not exceed 50 consecutive code blocks. Up to 70 rows <br/> * use local variables whenever possible. <Br/> * if global resources, such as connection, are involved, try to pass in as a function parameter <br/> * all resources created and opened in the function, you must disable release before exiting the function. For example, recordset, command <br/> 3.2.4 request, session, and application usage specifications <br/> * all objects to be put into the session and application must use meaningful English names. Except for the widely used word abbreviations, you cannot use them. For example, <br/> SESSION ("CP") = strcurrentuserip' is not allowed <br/> SESSION ("currentuserip") = strcurrentuserip <br/> SESSION ("PWD ") = strpwd 'Allow, PWD is widely known as a password <br/> * all elements in the request, session, and application that need to be used in the code, variables declared in the Code must be assigned to the Code header. <Br/> * if you get the content submitted in form, you must use request. form ("itemname "). <br/> * if you get the content submitted in querystring, you must use request. querystring ("itemname") <br/> * the request ("") cannot appear in the code. this reference method <br/> 3.2.5 principles of hybrid use of HTML and server-side scripts <br/> * server-side script mark "</P> <Table> <br/> do while not Rs. EOF <br/>%> <br/> <tr> <TD> text </TD> <p> <br/> </tr> <p> <br/> rs. movenext <br/> loop <br/> %> <br/> </table> <p> <br/> * the server script mark "*" %> "is the same as its the preceding Code cannot be written in the same line <br/> * server scripts Mark "%>" with its latest "* the HTML code inside the server is written according to the HTML indent rules of static files, does not follow the server-side script indent rules <br/> * HTML marks internal code, according to the server-side script indent rules, do not follow HTML code indent rules </P> <p> Chapter 4 Common Errors <br/> 1. ado transaction processing <br/> error code 1.1: 80004005. <Br/> 1.1.1 error description: <br/> Microsoft ole db provider for ODBC drivers error '000000' <br/> transaction cannot be started in firehose mode <br/> 1.1.2 solution: <br/> when starting an ADO transaction, you must first close the record set opened with the same connection object, or before opening those cursor sets, set the cursor set location type to aduseclient. (use client cursor set) <br/> Chapter 5 examples of code habits <br/> 1. ADO object usage <br/> 1.1 ADODB. connection object <br/> 1.2 ADODB. command object <br/> 1.3 ADODB. recordset object <br/> 1.3.1 created: <br/> set rs = server. createobject ("adod B. recordset ") <br/> Rs. cursorlocation = aduseclient <br/> Rs. open strsql, Conn, 1 [, 1] 'must specify the cursor type </P> <p> 1. annotation specification <br/>. annotation standard: <br/> L function annotation <br/> function annotation refers to the annotation to explain the Code itself. <Br/> the annotator uses "'" as the unified annotator. <Br/> 1. intra-row comments <br/> use the comment symbol "'" <br/> example: <br/> dim intfileno as integer "cannot be used to obtain the call number <br/> 2. whole Line (including multiple rows) comment <br/> block start and block end signs <br/> 36 </P> <p> '************** * ******************* <br/> '<br/> '********************************** <br /> L revision comments <br/> revision comments indicate the purpose of testing or correction, the Code has been changed, but the modification must be described and highlighted, and the original code must be added to the comment block. <Br/> if there is any change, the modification part of the logo is clearly explained by setting the comment block start and block end signs for both single and multiple lines, it is easy to find and distinguish the code segments with more comments. <Br/> 15 </P> <p> '***************** modify start ********* * ***** <br/> '</P> <p> '*********** * *** end **************** <br/> B. description: <br/> Declaration definition <br/> comments each constant declaration. <br/> comments the declaration of each variable, class, object, and so on; <br/> annotate each custom function definition. <br/> annotate each custom subroutine definition. <br/> Code <br/> annotate each component, comment on the top. <br/> comment on the branch selected for each condition. <br/> comment on the key points mentioned in each detailed design; <br/> comment out the use of global variables. </P> <p> C. comments: <br/> L comments to the variable and constant declaration section are in-line comments. Describe its purpose. </P> <p> note at the top of the definition section of L user-defined functions and subroutines: <br/> '*********************************** * <br/> 'summary: <br/> 'function Description: <br/> 'parameter description: <br/> 'Return value: <br/>' remarks: <br/> '*********************************** * </P> <p> L intra-row comments in the Code <br/> describe the operation rules of the specific code, loop content, counter purpose, and so on. </P> <p> L revision comments <br/> '***************** modify start ******** * ****** <br/> 'reasons for revision: <br/> 'revision history: <br/> 'Revised by date <br/> 'original code: <br/> 'case 5 to 8 <br/> '...... <Br/> case 4 to 8 <br/> '**************** end *********** * *** </P> <p> D. annotation method: <br/> you can add comments to the end of a line (the line width cannot be violated ); <br/> you can add a simple comment on a single line of code in the form of "'" in the previous line. <br/> place the comment on the entire code segment before the code segment; <br/> the annotator uses "'". </P> <p> II. Naming Conventions <br/> A. General principles <br/> the Reserved Words in Visual Basic can be viewed in the Visual Basic designer based on color changes. Variable naming cannot use reserved words. Meaningful names should be used. Abbreviation and meaningless names such as A and X1 cannot be used. Even for variables that are only used for cyclic counting, they should be uniformly assigned with meaningful names, such as longcnt. <Br/> the name cannot be too long and should be as concise as possible. The length limit should be within 32 characters. </P> <p> B. constants <br/> all use uppercase letters to indicate the names of nouns indicating the meaning of constants. The type of constants is not distinguished: <br/> const defaultconcentration as single = 0.01 </P> <p> C. variable <br/> names must be case-sensitive (VB Editor automatically converts to reduce the chance of program errors) <br/> variable naming adopts [range prefix] [array prefix] [type prefix] + [custom name] <br/> Control naming adopts [control prefix] + [custom naming] </P> <p> variable range prefix <br/> range prefix example <br/> global variable g gstrusername <br/> module-level M mstrusername <br/> no strusername at the process level <br/> array Prefix: A <br/> type Prefix: <br/> data type prefix example <br/> Boolean bln blnfound <br/> Te BYT bytrasterdate <br/> currency cur curbalance <br/> date DTM dtmbegindate <br/> double DBL dbl1_< br/> integer int intqty <br/> long LNG lngvcid <br /> single Sng sngaverage <br/> string STR stritemid <br/> Object OBJ objrmtsvr <br/> ADODB. recordset rst rstitem <br/> ADODB. connection CNN cnnnewspaper <br/> ADODB. command CMM cmaddcustomer <br/> variant vnt vntcheck <br/> Custom type UDT udtuserinfo <Br/> control type naming prefix <br/> example of control type prefix <br/> ADO data ADO adobiblio <br/> check box chk chkreadonly <br/> combo box, drop-down list box CBO cboenglish <br/> command button cmd cmdexit <br/> Common Dialog DLG dlgfileopen <br/> data-bound combo box dbcbo dbcbolanguage <br/> data- bound grid dbgrd dbgrdqueryresult <br/> data-bound list box dblst dblstjobtype <br/> data combo dbcauthor <br/> Data Grid DG D dgdtitles <br/> data list DBL dblpublisher <br/> directory list box dir dirsource <br/> drive list box DRV drvtarget <br/> file list box fil filsource <br/> form frm frmentry <br/> frame FRA fralanguage <br/> graph gra grarevenue <br/> grid GRD grdprices <br/> horizontal scroll bar HSB hsbvolume <br/> image img imgicon <br/> image combo imgcbo imgcboproduct <br/> imagelist ILS ilsallicons <br/> Label LBL lblhelpmessage <br/> line Lin linvertical <br/> list box lst lstpolicycodes <br/> listview LVW lvwheadings <br/> menu MNU mnufileopen <br/> month view mvw mvwperiod <br/> MS chart ch chsalesbyregion <br/> MS flex grid MSG msgclients <br/> MS tab MST mstfirst <br/> Option Button opt optgender <br/> picture box PIC picvga <br/> progressbar PRG prgloadfile <br/> Remote Data RD rdtitles <br /> Slider SLD sldscale <br/> spin spnpages <br/> statusbar sta stadatetime <br/> sysinfo sys sysmonitor <br/> tabstrip tab taboptions <br/> text box txt txtlastname <br/> timer TMR tmralarm <br/> toolbar TLB tlbactions <br/> Treeview tre treorganization <br/> updown UPD upddirection <br/> vertical scroll bar VSB vsbrate <br /> Develop the prefix of ActiveX control by yourself according to the design rules of the specific project. </P> <p> D. Tag <br/> the tag is the code ID used for the Goto jump. Because the Goto is not recommended, the tag is also demanding. All labels must be in uppercase, and the spaces in the middle must be replaced by underscores (_). They must begin with underscores (_). For example: <br/> _ a_label_example: <br/> tags are defined to be fully different from other code elements. </P> <p> E. Method <br/> both functions and subprograms must be named by a verb or verb phrase. No need to distinguish between functions and subprograms, or specify the return type. <Br/> sub open (byval strcommandstring as string) <br/> function setcopynumber (byval intcopynumber as integer) as integer <br/> you must specify the byval or byref parameter, this will increase the length of the program, but it is necessary. If not, use byval. For the parameter naming method, refer to "variable naming method ". </P> <p> 3. Writing format specifications <br/>. program writing sequence <br/> Brief description of the component <br/> variable declaration <br/> Process Declaration <br/> code segment 1 <br/> code segment 2 <br /> ...... <Br/> B. case <br/> the prefix of the variable name range must be in lower case, the first letter of each word is capitalized. <br/> functions, procedures, and object names must also be capitalized at the beginning of each word. <br/> C. indent <br/> unify the development environment, set the development environment option of the Visual Basic designer, and define the tab width to 4. When the code is indented, first select the code block to be indented, and then use the shortcut keys tab (right shift) and SHIFT + tab (left shift). If you manually enter a space to indent, the Unit is 4 spaces. <Br/> indent after the if statement; <br/> indent after the else statement <br/> indent after the select case statement <br/> indent after the DO statement <br/> indent after a for statement <br/> each row of a statement that has been separated by a row connection character must be indented <br/> indent after a with statement. <Br/> indent the Code marked from the row. </P> <p> D. space <br/> the operator must contain spaces, including: +,-, *,/, ^, =,>,> =, not, And, or; <br/> E. empty rows <br/> the variable declaration part and the code statement are separated. <br/> An empty row is inserted between each statement group that executes the Unified Task. Good code should be composed of processes or related statement groups in a logical order. <Br/> F. page width <br/> for long statements, such as API declarations, wrap lines within the visible range of the code form. Do not make it possible for others to view the complete code through a rolling window, the code length of a single row cannot exceed 95 columns. <Br/> use the "& _" line break. <Br/> G. Others <br/> in the project team, the parameters of the Visual Basic development environment are unified as needed. </P> <p> 4. Code check <br/> code check criteria <br/> complete comments, naming conventions, clear and readable codes are considered as qualified codes.. <Br/> check method <br/> failure to comply with the code specification is deemed as unqualified; </P> <p> 5. coding standards <br/> L sometimes, good programming principles may be violated, or some informal methods may be used. In this case, you must describe in detail what you are doing and why you want to do so. <Br/> for highly skillful code segments, you must add detailed comments instead of letting other developers spend a long time researching a highly skillful but hard-to-understand program segment. <Br/> L indent the comment to align it with the subsequent statement. <Br/> comments are usually located at the beginning of the Code to be explained. To visually highlight the relationship between the annotation and its code, indent the annotation, make it at the same level as the Code </P> <p> 6. ambiguity arising from the understanding of other <br/> documents is explained by the project owner of the project that references this document. </P> <p> posted on wddavid read (...) comment (...) edit favorites <p> refresh comments and refresh the page. Return to the top. <p> blog homepage: Ask the news flash programmer recruitment knowledge base. <p> <! -- Done --> </P> <p> copyright 2013 wddavid powered by: the blog garden template provides: hujiang blog <p> </option> <p> </SELECT> <p>

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.