VB.NET programming specification (2)

zhaozj2021-02-17  54

4.2 Variables and constant naming specifications

Array Arr ArrshoppingList

Boolean BLN BLNISPOSPOSPOSPOSPOSPOSPOSPOSPOSTBACK

Byte Byt bytpixelvalue

Char chr chrdelimiter

DateTime DTM DTMStartDate

Decimal Dec DecaverageHeight

Double DBL DBLSIZEOFUNIVERSE

Interger Int Introwcounter

Long LNG

Object obj

Short SHR

Single SNG

String Str

4.3 Function Process Naming Specification

4.3.1 Unified Word Order :: Letter Name

4.3.2 The first letter of the word is capitalized and the name should be able to express their use (or meaning).

4.3.3 Parameter Need to indicate BYVAL or byref (parameter is passed by value or transferred by address)

4.4 Class Naming Specifications

I. Class declared in Class, must be named by nouns or noun phrases, reflecting the role of classes

II. When the class is a characteristic (Attribute), at the end of Attribute, when the class is an exception, the EXCEPTION End: Class ColorseTexceptionClass CauseexceptionAttribute

III. When a class only needs an object instance (global object, such as Application et al), you must end with Class ScreenClassClass SystemClass.

Iv. When class is only used as a base class other than other classes, according to the situation, the end of the BASE: Mustinherit Class IndicatorBase

v. If the defined class is a form, then the name must be added to form, if it is a web form, you must add a suffix Page: Class Printform: Inherits Form '* Windows Forms StartPage: Inherits Page' * Web Window The body Vi. Module is not type, his name must be added to Module in addition to noun

: Module SharedFunctionsModule

Five Design Specifications:

5.1 Objects Received Variables to Variables or Controls Need to judge whether the object is a Nothing Example:

IF not customer is nothing then

Else

'Missing customer data is handled by the account and logon pages

END IF

5.2 Instead of replacing meaningless values ​​with meaningful constants when using the DataSet object:

Correct: with customer.tables (CustomerData.customers_table) .rows (0)

TXTEMAIL.TEXT = CSTR (.ITMERDATA.EMAIL_FIELD))

End with

WrM: with customer.tables (0) .rows (0)

TXTEMAIL.TEXT = CSTR (.Item (0))

TXTEMAIL.TEXT = CSTR (.item ("email"))

End with

5.3 Removal of extra spaces when taking a text box value:

Tmpassword = countrytextbox.text.trim ()

5.4 Two-story nesting or above If else endiff considers the use of SELECT CASE statement:

Wrong: if DataGrid1.Items (i) .Cells (4) .text = "0" THEN

Elseif DataGrid1.Items (i) .Cells (4) .text = "1" THEN

Elseif DataGrid1.items (i) .cells (4) .text = "2" THEN

DataGrid1.items (i) .cells (4) .text = "Trained"

END IF

Correct: Select Case DataGrid1.Items (i) .Cells (4) .Text

Case "1"

Case "2"

Case "3"

Case Else

End SELECT

5.5 INSERT statement correct format: INSERT [INTO] TableName (FieldName1, FieldName2), Values ​​(Value1, Value2)

Error format: insert [inTo] Tablename Values ​​(Value1, Value2)

Convenient table expansion

5.6 All operations must be shortcuts, support keyboard operations

5.7 Use do ... loop Replace While ... End while loop 5.8 Do not use Boolean Expressions with Ture or false more incorrect usage: iSemptyRecordset = (RS.eof = Tuue) correct usage : ISemptyRecordset = RS.EOF and RST.EOF if not (blnvalidTemplate). The 5.9 Even if the expression does not require parentheses, in order to logically clear, add the cracker 5.10 to call the SUB process to call the SUB process Call Keyword (Differently Differential Call without Return Value) Incorrect Usage PerformWordMerge (strMergefile): Call PerformWordMerge 5.11 Even if the function is not returned, it is necessary to always accept the return value of 5.12 using RETURN Return Function. Value incorrect usage: priavire function myfunction () as boolean myfunction = true end SUB Correct Usage: PriaVire Function MyFunction () AS Boolean Return True End Sub 5.13 Programming Rules All Constants Front Adding Prefix C_ and Scope Indicates Such like: process c_interestrate = 6 module (private) private const mc_intersrate = 6 global: public const gc_intersrate = 55.14 Never use string connectors, To use the & symbol 5.15 to group the relevant statement in IF ... ..Then, Select Case Structure Each cycle is inserted, inserting blank lines After declaring a set of variables, the statement of the same task is enhanced in the blank line process. Insert two blank line 5.16 to define a clear range of incorrect usage to each process: SUB DISP; LAY CONFIIRMATIONMESSAGE END SUB Correct Usage: Public Sub Disp; Lay ConfiirmationMAGE END SUB

........................ There is also an experience lesson in the actual programming. I hope everyone can sum up as my own standard.

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

New Post(0)