C# 命名規(guī)范
大家都知道寫程序應(yīng)該有個(gè)好的命名規(guī)范,為了工作方便,貼出來(lái)。 1 ADO.NET 命名規(guī)范
數(shù)據(jù)類型 |
數(shù)據(jù)類型簡(jiǎn)寫 |
標(biāo)準(zhǔn)命名舉例 |
Connection |
con |
conNorthwind |
Command |
cmd |
cmdReturnProducts |
Parameter |
parm |
parmProductID |
DataAdapter |
dad |
dadProducts |
DataReader |
dtr |
dtrProducts |
DataSet |
dst |
dstNorthWind |
DataTable |
dtbl |
dtblProduct |
DataRow |
drow |
drowRow98 |
DataColumn |
dcol |
dcolProductID |
DataRelation |
drel |
drelMasterDetail |
DataView |
dvw |
dvwFilteredProducts |
2 WinForm Control 命名規(guī)范
數(shù)據(jù)類型 |
數(shù)據(jù)類型簡(jiǎn)寫 |
標(biāo)準(zhǔn)命名舉例 |
Label |
lbl |
lblMessage |
LinkLabel |
llbl |
llblToday |
Button |
btn |
btnSave |
TextBox |
txt |
txtName |
MainMenu |
mmnu |
mmnuFile |
CheckBox |
chk |
chkStock |
RadioButton |
rbtn |
rbtnSelected |
GroupBox |
gbx |
gbxMain |
PictureBox |
pic |
picImage |
Panel |
pnl |
pnlBody |
DataGrid |
dgrd |
dgrdView |
ListBox |
lst |
lstProducts |
CheckedListBox |
clst |
clstChecked |
ComboBox |
cbo |
cboMenu |
ListView |
lvw |
lvwBrowser |
TreeView |
tvw |
tvwType |
TabControl |
tctl |
tctlSelected |
DateTimePicker |
dtp |
dtpStartDate |
HscrollBar |
hsb |
hsbImage |
VscrollBar |
vsb |
vsbImage |
Timer |
tmr |
tmrCount |
ImageList |
ilst |
ilstImage |
ToolBar |
tlb |
tlbManage |
StatusBar |
stb |
stbFootPrint |
OpenFileDialog |
odlg |
odlgFile |
SaveFileDialog |
sdlg |
sdlgSave |
FoldBrowserDialog |
fbdlg |
fgdlgBrowser |
FontDialog |
fdlg |
fdlgFoot |
ColorDialog |
cdlg |
cdlgColor |
PrintDialog |
pdlg |
pdlgPrint |
3 WebControl 命名規(guī)范
數(shù)據(jù)類型 |
數(shù)據(jù)類型簡(jiǎn)寫 |
標(biāo)準(zhǔn)命名舉例 |
AdRotator |
adrt |
Example |
Button |
btn |
btnSubmit |
Calendar |
cal |
calMettingDates |
CheckBox |
chk |
chkBlue |
CheckBoxList |
chkl |
chklFavColors |
CompareValidator |
valc |
valcValidAge |
CustomValidator |
valx |
valxDBCheck |
DataGrid |
dgrd |
dgrdTitles |
DataList |
dlst |
dlstTitles |
DropDownList |
drop |
dropCountries |
HyperLink |
lnk |
lnkDetails |
Image |
img |
imgAuntBetty |
ImageButton |
ibtn |
ibtnSubmit |
Label |
lbl |
lblResults |
LinkButton |
lbtn |
lbtnSubmit |
ListBox |
lst |
lstCountries |
Panel |
pnl |
pnlForm2 |
PlaceHolder |
plh |
plhFormContents |
RadioButton |
rad |
radFemale |
RadioButtonList |
radl |
radlGender |
RangeValidator |
valg |
valgAge |
RegularExpression |
vale |
valeEmail_Validator |
Repeater |
rpt |
rptQueryResults |
RequiredFieldValidator |
valr |
valrFirstName |
Table |
tbl |
tblCountryCodes |
TableCell |
tblc |
tblcGermany |
TableRow |
tblr |
tblrCountry |
TextBox |
txt |
txtFirstName |
ValidationSummary |
vals |
valsFormErrors |
XML |
xmlc |
xmlcTransformResults |
Array arr arrShoppingList Boolean bln blnIsPostBack Byte byt bytPixelValue Char chr chrDelimiter DateTime dtm dtmStartDate Decimal dec decAverageHeight Double dbl dblSizeofUniverse Integer int intRowCounter Long lng lngBillGatesIncome Object obj objReturnValue Short shr shrAverage Single sng sngMaximum String str strFirstName
二,
SqlServer命名規(guī)范
參考各種命名規(guī)范,我們統(tǒng)一使用命名規(guī)范如下:
命名過(guò)程中如有現(xiàn)存的縮寫,則使用該縮寫,如無(wú),一律不得縮寫,例:ISBN
數(shù)據(jù)庫(kù):用一個(gè)或三個(gè)以下英文單詞組成,單詞首字母大寫,如:DepartmentManage;
表名:使用名詞性質(zhì)的單詞全拼表示,各單詞首字母大寫, 使用復(fù)數(shù)形式,如:Books 如果該表用于表明另外兩表中字段間的關(guān)系,用單數(shù)(即表明實(shí)體間的關(guān)系的表用單數(shù)命名),單詞中間無(wú)“and of in”之類的介詞 如:BookAuthor
============================================================================================== 1. 表中的字段一般使用名詞性質(zhì)的單詞全拼表示,采用一個(gè)或三個(gè)以下英文單詞組成,單詞首字母大寫,如:UserName;
2. 表主鍵名稱為:表名+ID,如Document表的主鍵名為:DocumentID
3. 外鍵名稱位:主表名+對(duì)應(yīng)列名,如:DepartmentsID,說(shuō)明如下: 在表Departments中,其字段有:ID, DepartmentName 在表UserInfo中,其字段有:UserId,UserName,DepartmentsID DepartmentsID為外鍵
4. 表中自動(dòng)增長(zhǎng)的列一律命名為:ID;
5. 如果字段為bool型,則使用"IsShow","IsValid","HasPassed","HasExamined","IgnoreCase"這種形式表示
6. 如果字段位DateTime型,切且默認(rèn)值是取系統(tǒng)時(shí)間,一律命名位:CheckDate
7. Status為表中狀態(tài)的列名,默認(rèn)值為0,在表中刪除操作將會(huì)改變Status的值而不真實(shí)刪除該記錄;
8. 存儲(chǔ)過(guò)程命名:sp_表名_方法,如:sp_News_Add,sp_News_Update;
9. 視圖命名:vi_表名,如:vi_News;
10. 表、存儲(chǔ)過(guò)程、視圖等對(duì)象的所有都為dbo,不要使用數(shù)據(jù)庫(kù)用戶名,這樣會(huì)影響數(shù)據(jù)庫(kù)用戶的更改
|