ASP.NET Programming Specification

xiaoxiao2021-03-06  121

Part 1: Interface design standards

1. Development Environment Settings: Screen is set to 800 * 600/1024 * 768

2. Interface design principle: style must be unified

3. B / S Structure Development Principles: Use Frame / Template

4. The page is formatted using the table.

The outermost table setting: width = 778px align = center border = 0

5. Main page body setting: bgcolor = "# cccccc"

6. Frame sub-page Body setting: bottommargin = "0" leftmargin = "0"

7. Align: Text (label) right alignment; digital (data) right alignment; text (data) left alignment, relatively short can be aligned; amount, plus thousands of characters

8. The colon must be in the Chinese input state.

9. Control usage Principles: Use HTML controls as much as possible, you need to submit, without having to use JavaSRCIPT in the client to use web controls

10. Control usage conventions:

(1) Control appearance setting: style.css

I.I Link class:

A: Link {font-size: 12px; line-height: 20px; Text-Decoration: none; color: # 666666}

A: visited {font-size: 12px; line-height: 20px; color: # 66666; text-decoration:

None;}

A: Hover {font-size: 12px; line-height: 20px; color: # ff6600; text-decoration:

Underline;

A: Active {font-size: 12px; line-height: 20px; color: # 666666; Text-Decoration:

Underline;

I.II Form Category:

TD {font-size: 12px; line-height: 20px; text-decoration: none;

I.iii text box class:

.inputpm {border-right: # 99ccff 1px solid; border-top: # 99ccff 1px solid;

Border-left: # 99ccff 1px solid; border-bottom: # 99ccff 1px solid;

HEIGHT: 22PX}

I.IV DataGrid class:

.dg_grid / * Grid- overall * /

{font-size: 12px; border-style: solId; border-width: 2px; border-color: white;

TEXT-ALIGN: CENTER; VERTICAL-ALIGN: MIDDLE;

.dg_header / * Grid- Header * /

{font-weight: bold; color: # E7e7ff; Background-Color: # 3366cc; text-align: center

Vertical-align: middle; height: 25px;

.dg_alter / * Grid - Alternate line * /

{Background-Color: AliceBlue; Height: 22px;

.dg_item / * Grid - Ordinary line * /

{Color: Black; Background-Color: Whitesmoke; Height: 22px;}. DG_PAGE / * GRID-Page Navigation * /

{Color: Black; Text-align: Right; Vertical-Align: Middle; Height: 22px;

.dg_select {font-weight: bold; color: white; background-color: # 9471de;} / * grid- select line * /

(2) Some additions:

II.I Control DataGrid data display: text (short) is aligned; text (long) left alignment; the date left align; the number is left aligned; the amount is left aligned, thousands of characters

II.II Control TEXT length MaxLength is set by data structure

II.III Because the operation is mainly related to the database, the control type can be corresponding to the data table field (Field) type, which is approximately:

U field type is text, digital, the control uses text box

UF Types When you are a Boolean value, the control uses a single option button (CheckBox control) or drop-down box

The U field content is selected in a fixed several values ​​(regardless of its type), the control uses the drop-down frame.

U field type is the date time, the control uses the text box button (button can be selected, buttons .Value = "..."

The U field is the foreign key of other tables, divided into two cases:

a) If it belongs to basic information, the control uses a drop-down frame.

b) If it is not a basic material, the control uses the text box button (the button is used to jump out the query window, "said button .value =" ... "

u Data operation window is generally a DataGrid entry box

a), DataGrid is used to display data

b), entry box for input / display data

c), browse the basic style of the window, mainly in the form of form, single-table controls use DataGrid / Datalist / Repeater, multi-table uses NestedDataGrid

Part II: Naming Specifications

1. Button ID Name: BTN Button Operating Function (such as btnsave)

2. Other controls:

I. Related to data operations: Its ID <.span> is the corresponding field name. If there are multiple controls corresponding to a field, naming it below:

Field name "_" sequence number (beginning with 01)

Example: The page has a TextBox control, corresponding to the RightGroup field in the database table, its ID should be named RightGroup

If the page has two TextBox controls, all corresponds to the PowerGroup field in the database table, and its ID is named powerGroup_01, PowerGroup_02, and so on

II. Others: Prefix Use function (such as txtinput), prefix table 1:

Controls prefix controls the prefix Form frm Class cls / C Module mod Label lbl LinkLabel lnk Button btn TextBox txt CheckBox chk RadioButton rad GroupBox grp PictureBox pic DataGrip grd ListBox lst CheckedListBox clst ComboBox cbo TreeView tvw ListView lvw TabControl tab DateTimePicker dtp Timer tmr Splitter spl ProgressBar pbar RichtextBox RTF ImageList Imgl Toolbar TLB Menuitem Mnu (Table 1)

3. Variables and constant naming specifications:

I. Page and process-grade variable: level identity data type prefix

A, page-level variable: level identifier is M (example: DIM MSTRNEWLINE AS STRING)

B, process grade variable: level logo is L (example: DIM LSTRNEWLINE AS STRING)

II. Page variables: Request delivery acquisition

Naming Principles: Level ID Data Type Prefix

Level logo is p

Example: URL = "xxxx.aspx? Pstrline = bbbbbb & pintnum =

11 "

DIM lstrline as string = request ("pstrline")

DIM LINTNUM AS INTEGER = Request ("PINTNUM")

Iii. Full level variable: level identification data type prefix

A, level logo: g (example: DIM GSTRNEWLINE AS STRING)

B, because all pages can be used, so there must be a sufficiently long name to explain the variable, and add notes

C, unified in the module

D, the definition of full-stage variables must be processed after the agreement of the project supervisor

IV. Universal variable: use session assignment

a, naming principle: level identity data type prefix

b, level identification is g (example: session ("gstrnewline") = "" "

C, because all pages can be used, so there must be a sufficiently long name to illustrate the variable, and add a comment

D, the general variable is uniformly placed in the session_start (e) in Global.asax, the initial value gives an empty string. And release it during the session_end (sender, e).

example:

Global.asax file:

Sub session_star (Byval EVENTARGS)

Session ("gstruser") = "" "

End Sub

Sub session_end (Byval E AS Object, ByVal E as Eventargs)

Session ("gstruser") = Nothing

End Sub

e, the definition of common variables must be processed after the agreement of the project supervisor

V. Data type prefix:

Data type prefix data type prefix String str Date dat Boolean bln Short sht Decimal dec Long lng Integer int Byte byt Char chr Single sgl Double dbl Structure udt Object obj DataSet ds DataRow dr OleDbConnection conn SqlConnection conn OleDbCommand cmd SqlCommand cmd OleDbDataAdapter da SqlDataAdapter da OleDbDataReader rdr SqlDataReader RDR Crystal Report RPT (Table 2)

4. Process (function) naming specification:

I. Name Specification: Level Identification

II. Apply to a single page: Level ID (example: private function pdisdata ())

Iii. Applicted to all pages: Level ID is G (example: public function gdisdata ())

5. Page Naming Specification: Module Identification Program Function English Abbreviation

I. Example: There is a basic data module, its module is identified as base, the English abbreviation used by the program is Unit, then the page name is BASEUnit

II. This name can only be set by the project supervisor or system analysis.

6. Storage procedure naming specification:

I. Name Specification: [Two letters before the project name] [program use English abbreviation] [_] [stored procedure function ID]

II. Convert to lowercase if the project name is uppercase

Iii. Example: The project name is Dkerp, the English abbreviation of the program role is Unit, and the function of the stored procedure is saved, and can be named DKUnit_SAV

IV. Store process function identification convention:

u>> is saved, its identifier is SAV

u Storage procedure function is deleted, its identifier is Del

u Storage procedure function is query, its identifier is QRY

u> The stored procedure function is filled to the control, its identifier is Back

u> The stored procedure function is binding downlift frame control, its identifier is DLL

V. Storage procedure naming and planning must pass after the agreement of the project supervisor

7. Class naming specification:

I. Principle: [CLS] , noun | The first letter of the verb

II. Example: ClsDataOperate

Iii. The definition of public class and naming must pass after the agreement of the project supervisor

8. Module naming specification:

I. Principle: [MOD] , noun | The first letter of the verb

II. Example: ModDataConnection

Iii. The definition and naming of the public module must be proceed after the agreement of the project supervisor

9. User Control Naming Specification:

I. Principle: [URL] , noun | The first letter of letters of verbs

II. Example: UrldatAload

Iii. The definition and naming of the user control must be the third part after the agreement of the project supervisor: coding specification

1. Comment

A. At the beginning of each page, you must have a note in the following format.

'***************************************************

'Page Name: frMstylee

'Effect / description: style query

'Enter / Send:

'StruserList (): The list of users searched.

'Strtargetuser: The user name to search.

'Output / Return Format: The index of RSTARGETUSE in the RASUserList array.

'If the target user is not found, returning -1.

'Author: Raymnod Fok

2002-1-1

'Original dates:

'editor:

'Modify date:

'Note:

'*********************************************************

Note: Left alignment, 4 TAB bits in the middle (4 digits per Tab)

B. All variables and constants must be comments

C. Each process (function) should also be annotated to describe the function of this process (function), the following is the format of the comment

'*******************************************************

'Function name: intfinduser

'Purpose: To find a first appearance location of a specified user in the user list array.

'Enter / Send:

'StruserList (): The list of users searched.

'Strtargetuser: The user name to search.

'Output / Return Format: The index of the RSTARGETUSER in the RASUserList array.

'If the target user is not found, returning -1.

'Parameters: INTCOL needs to get the current text

'Author: Raymnod Fok

2002-1-1

'Original dates:

'editor:

'Modify date:

'Note:

'*********************************************************

Function PintFinduser (StruserList () AS String, StrtargetUser AS String AS Integer

DIM I AS INTEGER 'Cycle Counter.

Dim BLNFOUND AS INTEGER 'Target Look.

INTFINDUSER = -1

i = 0

While i <= ubound (struserlist) and not blnfound

IF struserlist (i) = startergens

BLNFOUND = TrueintFinduser = i

END IF

Wend

END FUNCTION

D. Process (functions) or memory within the stored procedure

Should be divided according to the functional block, the comment should be written before each small algorithm or a small function, do not make a group with the code, notes

E. If you write a comment after the program code, start writing a comment after the three TAB bits behind the code statement

F. If the comment is part of the code in the program, you need to indicate the beginning and end of the segment code.

G. The stored procedure should also write a comment, the following is the format of the stored procedure comment

/ *

Stored procedure name: TsellMain_QRY

Role: Query the data of Sell_SellRecordmain

enter:

Output: Table Sell_SellRecordMain all data

Author: quanysq

date:

editor:

Modify date:

Remarks:

* /

Create Procedure TSELLMAIN_QRY

AS

Select * from sale_sellrecordmain

Go

2. Formatting code

A. The nesting block should have a strict hierarchy indent (1 Tab, each layer, Note: Each Tab is 4 English characters)

B. A process or function cannot be too long, and should be generally limited to 200 lines, otherwise it should be split into multiple processes or functions.

C. When generating a long string, use the underline connection character to generate multiple lines of code.

D. When accessing databases, saves, deletes, displays data, etc., uniformly uses public classes.

E. When making an interface, it is necessary to control the standard, and the interface is consistent with the process, and the interface must also meet the standard specification.

F. When reading data is displayed to the interface, you should understand the validity of the process and the validity of the tables and fields in the database, and the data displayed is completely correct.

G. When processing operation interface data, it is consistent with the data validity in the database, and the data is consistent with the process and ensures that the data is valid. Data should be rational (eg quantity should be less than 0 or greater than 0, decimal points, etc.)

H. In the save data processing, you should find the desired, the saved data should be consistent with the interface data, and the process is compliant with the process.

I. Displayed on the interface, interface data operation, save data operation, to reduce control points, so that the program is systematically

J. For the naming of variables, remember to specification

K. Add more comments in the program to make the program more clear

L. When exiting the page, you must release the variable that will reside in memory in the page_disposed (e) event, mainly the session variable, DataSet variable

M. The flowchart must be a brief plan to plan the process of procedure, where the name of the module that implements this feature

N. Flowchart Name: Same as the program name

O. When the enabled property of the TextBox control is false, its background color must be gray (color name: Silver)

P. Switch the current control, in addition to the default Tab keys of VB.NET itself, plus Enter

Q. About concurrency control, generally take a transaction lock method, there are three situations:

a. Locked the entire table, usually happen to use the TabLockx prompt when querying a lot of data.

Example:

Create Procedure Tsellmain_QRYAS

Begin Transaction

Select * from sell_sellrecordmain with (Tablockx)

IF @@ error> 0

Rollback

Else

Commit ---- Release lock when submitted or rolling

Go

b. Apply for all the records in the update table to apply to lock to prevent the impact of other users before committing transactions.

Set Transaction Isolation Level Serializable

Example:

Create Procedure Ttesthr_Update

AS

Begin Transaction - Starting affairs

SET Transaction Isolation Level Serializable - Apply a row lock to prevent the impact of other users before committing transactions

Update Testhr Set Hrcode = 'AAA'

IF @@ error> 0

Rollback

Else

Commit ---- Release the row lock when submitted or rolled

Go

c. Use the row lock if it is just updated in the table or multi-line record.

With (Rowlock)

Example:

Create Procedure Ttesthr_Update

AS

Begin Transaction - Starting affairs

Update Testhr with (Rowlock) Set Hrcode = 'AAA' Where Hrcode = 'BBB'

IF @@ error> 0

Rollback

Else

Commit ---- Release the row lock when submitted or rolled

Go

R. Processing errors in the program generally use the following structure

Try

Code

Catch

... error message

Finally

... release variables that may reside in memory

END TRY

Part IV: Test Specification

1. Before the test, you can use a summary design manual. Detailed design manual as a total outline, select the appropriate input and output data.

2. Test separately by function module

3. During the test, the subunit processes must first be tested, and after each sub-unit process test is completed, the interfaces between each module (including the interface between each sub-unit process) are processed, and the interface between the modules is processed. Finally, test and maintenance of the system.

4. Need to pay attention to the test:

a. Data type does not match.

Such as: Name String Travel Destination String

Gender String Travel Time Date

Work unit String (Year / month / day yy / mm / dd)

ID card number long INT ticket / ticket Boolean

b. Data beyond the specified range

Such as: Gender can only be 'male' or 'female'; ID card number must be 13 in accordance with the regulations; travel time must be a day after the ticket;

c. Database qualification must be input in the program?

d. Database Limit value is the only test in the program?

e. Is the control DataGrid's paging program written well, is there any test?

f. Is the width of the control DATAGRID allocated?

g. Is the link correct?

h. Will the code are simple, will it leave some security hazards?

I. Is there any other prevention code outside of other expectations? J. Is it in line with the needs? Is the demand clear?

5. Test principle: If you can't satisfy your own, others will not be satisfied.

转载请注明原文地址:https://www.9cbs.com/read-103037.html

New Post(0)