命名规范01 for Asp.Net
2010-07-03 11:34
281 查看
程序设计之命名规范
撰写人:田振宇1. 前 言
程序设计工作是项目实施中的重要环节,是确保产品质量与工作成果的直接体现。我们知道一个软件产品的程序实现可以拆分为很多细节工作,就代码而言:程序员与程序员之间、测试人员与程序员之间、项目经理与程序员之间讨论最多的是功能实现。而具体功能的实现最终都要归结到代码。如何编写易懂、易读的程序代码,是程序设计工作的重点。更重要的是它确保众多角色协同工作时,对问题的描述过程变的准确而有效。我们不说:“编程就象艺术”,但是一个编程老手与一个新人之间的区别不仅仅反映在工资待遇上,同时也反映在他们对工作任务的实际操作。因此,如果你是一名程序设计人员,在加入到一个开发团队中,请在适当的时候向负责人索要『命名规范』 ,如果项目中没有这个环节,也不一定是一件坏事,它正是你展现自我能力的机会。
2. 定义命名规范的意义
命名规范简而言之就是:对程序设计中编写字符串的排列组合,给予一些人为的约束。约束的目是让字符串经过人的视觉神经传入大脑后,立即展现它的现实意义。如:它代表什么控件、什么功能、生命周期、数据类型等。对于持续性的开发工作,好的命名规范至少可以帮你节省10%以上的精力,这个请绝对相信。
同时,命名规范还被用到代码测试、代码质量分析、项目风险评估等工作中。
3. 命名规范的使用过程
使用命名规范首先要知道,命名规范不是一程不变的。无论已往的项目多么成功,它的『命名规范』也不要全部照搬。因为“项目”本身具有独特性,这个特性要在命名规范中反映出来。3.1、了解别人的编程习惯
由参与程序工作的人员共同构件命名规范,要比从别处照般一份有意义的多。因为每个组员编程多少都会有一些个人习惯。所以使用命名规范的第一步骤是:沟通,了解别人的编程习惯。
3.2、了解项目的具体开发环境
你是使用.Net IDE环境做这个项目呢,还是JAVA呢?甚至是C++。那编程环境就不一样了。环境对控件的命名也不一样。所以,先了解你的任务开发环境,熟悉你的编程工具很重要。
3.3 、一份有意义的文挡
“命名规范文档”当然是必不可少的了,所以现在就应该建立一份『XXX程序开发命名规范』了。但是,里面该有那些内容呢?
4. 掌握命名规范的前题
建立与使用『XXX程序开发命名规范』实际是一个过程。那么命名规范中需要写哪些东西?恩!英文首先要好。毕竟代码你还是用阿拉伯字母编写,毕竟英文的定义准确、输入简便。所以第一件事情是:查查字典,把任务中提到过的业务从英文字典中找出来。更有专门的计算机专业词典,甚至是命名规范体系的书籍可以帮到你的忙。然后请使用下面的文档信息吧。摸索、尝试与总结,经过这个过程后,你会说『命名规范』真是有用,不过『命名规范』它不过如此!
5.命名规则
1.[首单词]+[后续单词]+[再后续单词]2.首字母小写,后续字段首字母大写加以区分;
3.首个单词含义为:控件类型或数据类型,具体参照命名规范文档。首个单词字母全部小写;
4.后续单词定义为内容实际内容;
5.再后续内容为所属作用域范围,如:控件名、页面名、表单名等。
6命名规范文档
1、数据类型数据类型 | 数据类型简写 | 标准命名举例 | 含义 | |
1 | Array | arr | arrShoppingList | |
2 | Boolean | bln | blnIsPostBack | |
3 | Byte | byt | bytPixelValue | |
4 | Char | chr | chrDelimiter | |
5 | DateTime | dtm | dtmStartDate | |
6 | Decimal | dec | decAverageHeight | |
7 | Double | dbl | dblSizeofUniverse | |
8 | Integer | int | intRowCounter | |
9 | Long | lng | lngBillGatesIncome | |
10 | Object | obj | objReturnValue | |
11 | Short | shr | shrAverage | |
12 | Single | sng | sngMaximum | |
13 | String | str | strFirstName |
控件类型 | 缩写 | 含义 | 示例 | |
1 | Animated button | ani | aniMailBox | |
2 | Button | btn | ||
3 | Check box | chk | chkReadOnly | |
4 | ColorDialog | clrdlg | ||
5 | Combobox,drop-down list box | cbo | cboEnglish | |
6 | Communications | com | comFax | |
7 | ContextMenu | ctxmnu | ||
8 | Control(used within procedures when the specific type is unknown) | ctr | ctrCurrent | |
9 | CrystalReportViewer | crvw | ||
10 | Data | dat | datBiblio | |
11 | Data grid | dgd | dgdTitles | |
12 | Data list | dbl | dblPublisher | |
13 | Data repeater | drp | drpLocation | |
14 | Data-bound combo box | dbcbo | dbcboLanguage | |
15 | Data-bound grid | dbgrd | dbgrdQueryResult | |
16 | Data-bound list box | dblst | dblstJobType | |
17 | Datetime picker | dtp | dtpPublished | |
18 | Directory list box | dir | dirSource | |
19 | DomainUpDown | dupd | ||
20 | Drive list box | drv | drvTarget | |
21 | ErrorProvider | err | ||
22 | File list box | fil | filSource | |
23 | Flat scroll bar | fsb | fsbMove | |
24 | FontDialog | fntdlg | ||
25 | Form | frm | frmEntry | |
26 | Frame | fra | fraLanguage | |
27 | Gauge | gau | gauStatus | |
28 | Graph | gra | graRevenue | |
29 | Grid | grd | grdPrices | |
30 | GroupBox | grp | ||
31 | HelpProvider | hlp | ||
32 | Hierarchical flexgrid | flex | flexOrders | |
33 | HScroll bar | hsb | hsbVolume | |
34 | Image | img | imgIcon | |
35 | Image combo | imgcbo | imgcboProduct | |
36 | ImageList | ils | ilsAllIcons | |
37 | Label | lbl | lblHelpMessage | |
38 | Line | lin | linVertical | |
39 | LinkLabel | lnk | ||
40 | List box | lst | lstPolicyCodes | |
41 | ListView | lvw | lvwHeadings | |
42 | MAPI message | mpm | mpmSentMessage | |
43 | MAPI session | mps | mpsSession | |
44 | MCI | mci | mciVideo | |
45 | Menu | mnu | mnuFileOpen | |
46 | Month view | mvw | mvwPeriod | |
47 | MonthCalendar | mcl | ||
48 | MS Chart | ch | chSalesbyRegion | |
49 | MS Flex grid | msg | msgClients | |
50 | MS Tab | mst | mstFirst | |
51 | NotifyIcon | nti | ||
52 | NumericUpDown | nupd | ||
53 | OLE container | ole | oleWorksheet | |
54 | OpenFileDialog | ofdlg | ||
55 | PageSetUpDialog | psdlg | ||
56 | Picture box | pic | picVGA | |
57 | Picture clip | clp | clpToolbar | |
58 | PrintDocument | prndoc | ||
59 | PrintPreviewControl | ppctl | ||
60 | PrintPreviewDialog | ppdlg | ||
61 | ProgressBar | prg | prgLoadFile | |
62 | RadioButton | rbtn | ||
63 | Remote Data | rd | rdTitles | |
64 | RichTextBox | rtf | rtfReport | |
65 | SaveFileDialog | sfdlg | ||
66 | Shape | shp | shpCircle | |
67 | Slider | sld | sldScale | |
68 | Spin | spn | spnPages | |
69 | Splitter | spt | ||
70 | StatusBar | sta | staDateTime | |
71 | SysInfo | sys | sysMonitor | |
72 | TabContrl | tab | ||
73 | TabStrip | tab | tabOptions | |
74 | Text box | txt | txtLastName | |
75 | Timer | tmr | tmrAlarm | |
76 | Toolbar | tlb | tlbActions | |
77 | TrackBar | trb | ||
78 | TreeView | tre | treOrganization | |
79 | UpDown | upd | updDirection | |
80 | VScroll bar | vsb | vsbRate |
数据类型 | 数据类型简写 | 标准命名举例 | |
1 | Connection | conn | connNorthwind |
2 | Command | cmd | cmdReturnProducts |
3 | Parameter | parm | parmProductID |
4 | DataAdapter | dad | dadProducts |
5 | DataReader | dtr | dtrProducts |
6 | DataSet | dst | dstNorthWind |
7 | DataTable | dtbl | dtblProduct |
8 | DataRow | drow | drowRow98 |
9 | DataColumn | dcol | dcolProductID |
10 | DataRelation | drel | drelMasterDetail |
11 | DataView | dvw | dvwFilteredProducts |
数据类型 | 数据类型简写 | 标准命名举例 | |
1 | Label | lbl | lblMessage |
2 | LinkLabel | llbl | llblToday |
3 | Button | btn | btnSave |
4 | TextBox | txt | txtName |
5 | MainMenu | mmnu | mmnuFile |
6 | CheckBox | chk | chkStock |
7 | RadioButton | rbtn | rbtnSelected |
8 | GroupBox | gbx | gbxMain |
9 | PictureBox | pic | picImage |
10 | Panel | pnl | pnlBody |
11 | DataGrid | dgrd | dgrdView |
12 | ListBox | lst | lstProducts |
13 | CheckedListBox | clst | clstChecked |
14 | ComboBox | cbo | cboMenu |
15 | ListView | lvw | lvwBrowser |
16 | TreeView | tvw | tvwType |
17 | TabControl | tctl | tctlSelected |
18 | DateTimePicker | dtp | dtpStartDate |
19 | HscrollBar | hsb | hsbImage |
20 | VscrollBar | vsb | vsbImage |
21 | Timer | tmr | tmrCount |
22 | ImageList | ilst | ilstImage |
23 | ToolBar | tlb | tlbManage |
24 | StatusBar | stb | stbFootPrint |
25 | OpenFileDialog | odlg | odlgFile |
26 | SaveFileDialog | sdlg | sdlgSave |
27 | FoldBrowserDialog | fbdlg | fgdlgBrowser |
28 | FontDialog | fdlg | fdlgFoot |
29 | ColorDialog | cdlg | cdlgColor |
30 | PrintDialog | pdlg | pdlgPrint |
数据类型 | 数据类型简写 | 标准命名举例 | |
1 | AdRotator | adrt | Example |
2 | Button | btn | btnSubmit |
3 | Calendar | cal | calMettingDates |
4 | CheckBox | chk | chkBlue |
5 | CheckBoxList | chkl | chklFavColors |
6 | CompareValidator | valc | valcValidAge |
7 | CustomValidator | valx | valxDBCheck |
8 | DataGrid | dgrd | dgrdTitles |
9 | DataList | dlst | dlstTitles |
10 | DropDownList | drop | dropCountries |
11 | HyperLink | lnk | lnkDetails |
12 | Image | img | imgAuntBetty |
13 | ImageButton | ibtn | ibtnSubmit |
14 | Label | lbl | lblResults |
15 | LinkButton | lbtn | lbtnSubmit |
16 | ListBox | lst | lstCountries |
17 | Panel | pnl | pnlForm2 |
18 | PlaceHolder | plh | plhFormContents |
19 | RadioButton | rad | radFemale |
20 | RadioButtonList | radl | radlGender |
21 | RangeValidator | valg | valgAge |
22 | RegularExpression | vale | valeEmail_Validator |
23 | Repeater | rpt | rptQueryResults |
24 | RequiredFieldValidator | valr | valrFirstName |
25 | Table | tbl | tblCountryCodes |
26 | TableCell | tblc | tblcGermany |
27 | TableRow | tblr | tblrCountry |
28 | TextBox | txt | txtFirstName |
29 | ValidationSummary | vals | valsFormErrors |
30 | XML | xmlc | xmlcTransformResults |
相关文章推荐
- Visual C#中的winform/webform/asp.net控件命名规范
- ASP.NET 编程命名规范
- ASP.NET 控件命名规范
- asp.net控件命名规范
- asp.net 命名规范
- 不规范的命名对ASP.NET中基于窗体的自定义身份验证的影响
- asp.net命名规范
- 程序命名规范ASP.net
- Asp.Net 控件命名规范
- asp.net 命名规范
- asp.net 命名规范
- Visual Studio C#的winform/webform/asp.net控件命名规范
- 找不到ASP.NET AJAX控件的命名规范
- ASP.NET WEB开发规范_控件命名规范
- 一个asp.net控件的命名规范
- ASP.NET 控件命名规范
- VS.NET 2003 控件命名规范(Asp.net版)
- ASP.NET(C#)命名规范(前缀)
- 从命名规范到架构——我的ASP.NET历程(起稿)
- ASP.NET(C#)命名规范(前缀)