国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

引言:Kent Beck 曾經說過"我只是個更注重的程序規范的程序員而已"

2024-07-21 02:21:09
字體:
來源:轉載
供稿:網友
4.2 變量和常數命名規范

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 函數過程命名規范

4.3.1統一的單詞順序::動詞+名次

4.3.2單詞的首個字母大寫并且名稱應該能表達出它們的用途(或者說是意義)。

4.3.3 參數需要指明byval還是byref(參數是按值傳遞還是按地址傳遞)



4.4 類命名規范

i. 以class聲明的類,都必須以名詞或名詞短語命名,體現類的作用

ii. 當類是一個特性(attribute)時,以attribute結尾,當類是一個異常(exception)時,以exception結尾:
class colorsetexception
class causeexceptionattribute

iii. 當類只需有一個對象實例(全局對象,比如application等),必須以class結尾,如
class screenclass
class systemclass

iv. 當類只用于作為其他類的基類,根據情況,以base結尾:
mustinherit class indicatorbase

v. 如果定義的類是一個窗體,那么名字的后面必須加后綴form,如果是web窗體,必須加后綴page:
class printform : inherits form '* windows窗體
class startpage : inherits page '* web窗體

vi. 模塊不是類型,他的名稱除了必須以名詞命名外,必須加以后綴module

:module sharedfunctionsmodule



五 設計規范:

5.1對象取值賦給變量或者控件時需要判斷對象是否為nothing 例:

if not customer is nothing then

else

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

end if

5.2 在使用dataset 對象時 用有意義的常量代替無意義的值 例:

正確的: with customer.tables(customerdata.customers_table).rows(0)

txtemail.text = cstr(.item(customerdata.email_field))

end with

錯誤的:with customer.tables(0).rows(0)

txtemail.text = cstr(.item(0))

txtemail.text = cstr(.item(“email”))

end with

5.3 取文本框數值的時候需要去除多余的空格例:

tmppassword = countrytextbox.text.trim()



5.4 兩層嵌套以上的 if else end if 考慮使用 select case 語句 例:

錯誤的: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 = "已培訓"

end if

正確的: select case datagrid1.items(i).cells(4).text

case “1”

case “2”

case “3”

case else

end select

5.5 insert 語句的正確格式:insert [into] tablename (fieldname1,fieldname2),values( value1,value2)

錯誤的格式: insert [into] tablename values (value1, value2)

方便表的擴充

5.6 所有的操作要有快捷鍵,支持鍵盤操作

5.7 用do……loop 循環代替 while…… end while 循環

5.8不要用boolean表達式與ture 或false比較

不正確的用法:isemptyrecordset= (rs.eof= ture) and( rst.eof=tuue)

正確的用法: isemptyrecordset= rs.eof and rst.eof

if not (blnvalidtemplate). then

5.9即使表達式不需要圓括號,為了邏輯清晰也要加上圓括號

5.10 使用統一和直接明了的方式調用過程

調用sub過程要使用call 關鍵字(區別于沒有返回值的函數調用)

不正確的用法 performwordmerge(strmergefile)

正確的用法:call performwordmerge(strmergefile)

5.11 即使沒有返回值的函數也要始終接受函數的返回值

5.12使用return 返回函數值

不正確地用法:priavire function myfunction () as boolean

myfunction =true

end sub

正確地用法:priavire function myfunction () as boolean

return true

end sub

5.13常量的編程規則

所有的常量前面加上前綴c_和范圍指示符

例如:過程中 const c_interestrate=6

模塊中(private)private const mc_intersrate=6

全局: public const gc_intersrate=5

5.14決不要用+做字符串的連接符,要使用&符號

5.15用空白行把相關的語句分組

在 if …..then ,select case 結構 每個循環體 的前后插入空白行

在聲明一組變量后,執行同一任務的語句組之后插入空白行

過程之間插入兩個空白行

5.16給每個過程定義一個明確的范圍

不正確地用法:sub disp;lay confiirmationmessage

end sub

正確地用法:public sub disp;lay confiirmationmessage

end sub

…………………….還有n條 都是自己在實際編程中的經驗教訓不在列舉了,希望大家也能總結一下作為自己的規范
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 仪陇县| 凤庆县| 威海市| 台江县| 平安县| 大石桥市| 延庆县| 柘城县| 蒙城县| 土默特左旗| 新和县| 大足县| 塔河县| 扶风县| 吉首市| 喀喇沁旗| 大足县| 乌审旗| 滨海县| 阳新县| 剑河县| 页游| 阿克陶县| 平原县| 乳山市| 定南县| 雷州市| 大新县| 靖江市| 高台县| 怀柔区| 应用必备| 丁青县| 资中县| 河池市| 溧水县| 淄博市| 吴旗县| 同心县| 化隆| 汾阳市|