Introduction: Kent Beck once said, "I'm just a programmer with a more focused code."

Source: Internet
Author: User
Tags case statement range
Program | programmer | Specification 4.2 variable and constant naming conventions

Array arr arrshoppinglist

Boolean bln Blnispostback

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 procedure Naming specification

4.3.1 Unified word order:: Verb + rank

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

The 4.3.3 parameter needs to indicate whether ByVal or byref (whether the argument is passed by value or by address)



4.4 Class Naming conventions

Classes declared by class, must be named after nouns or noun phrases to reflect the role of the class

Ii. when a class is an attribute, at the end of the attribute, when the class is an exception (Exception), End with Exception:
Class colorsetexception
Class Causeexceptionattribute

Iii. when a class simply has an object instance (global object, such as application, etc.), it must end with class, as
Class Screenclass
Class Systemclass

Iv. when the class is used only as a base class for other classes, as appropriate, end with base:
MustInherit Class Indicatorbase

V. If the defined class is a form, then the name must be appended with the suffix form, and if it is a Web form, the suffix page must be appended:
Class printform:inherits form ' * Windows Form
Class startpage:inherits Page ' * Web Form

Vi. module is not a type, except that his name must be named after the noun, it must be suffix module

: Module Sharedfunctionsmodule



Five Design specifications:

5.1 object is assigned to a variable or control, you need to determine if the object is nothing:

If not Customer are nothing Then

Else

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

End If

5.2 Use meaningful constants instead of meaningless values when using a DataSet object:

Correct: With Customer.tables (customerdata.customers_table). Rows (0)

Txtemail.text = CStr (. Item (Customerdata.email_field))

End With

Wrong: With Customer.tables (0). Rows (0)

Txtemail.text = CStr (. Item (0))

Txtemail.text = CStr (. Item ("Email"))

End With

5.3 When you take a text box value, you need to remove the extra space examples:

Tmppassword = CountryTextBox.Text.Trim ()



5.4 Two-layer nested if Else end if consider using the Select Case statement:

Error: 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 in the correct format: insert [into] tablename (fieldname1,fieldname2), VALUES (value1,value2)

Wrong format: Insert [into] tablename Values (value1, value2)

Expansion of convenient tables

5. 6 All operations need to have shortcut keys, support keyboard operation

5.7 Replace while with Do......loop loop ... end while loop

5.8 Do not compare Boolean expressions with Ture or false

Incorrect usage: isemptyrecordset= (rs.eof= ture) and (Rst.eof=tuue)

Correct usage: isemptyrecordset= rs.eof and Rst.eof

If not (blnvalidtemplate). Then

5.9 Even if the expression does not require parentheses, add parentheses for clarity of logic

5.10 Calling procedures in a unified and straightforward manner

Calling the Sub procedure uses the Call keyword, which differs from a function call that has no return value

Incorrect usage performwordmerge (strmergefile)

Correct usage: Call Performwordmerge (Strmergefile)

5.11 Even functions that do not return a value always accept the return value of the function

5.12 returning function values using return

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 for constants

All constants precede with the prefix C_ and range indicator

For example: The process of const C_INTERESTRATE=6

Module (private) Private Const mc_intersrate=6

Global: Public Const gc_intersrate=5

5.14 never use + to do the string connector, to use the & symbol

5.15 use blank lines to group related statements

Inserts a blank line before and after each loop body in the If ... then, select Case structure

After you declare a set of variables, insert a blank line after the statement group that executes the same task

Insert two blank lines between procedures

5.16 Define a definite range for each process

Incorrect usage: Sub Disp;lay confiirmationmessage

End Sub

Correct usage: Public Sub Disp;lay confiirmationmessage

End Sub

... there are also n all the lessons in the actual programming are not listed, I hope we can sum up as their own norms of the. s ...., ... and all of them.


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.