Programming Style

4.3 Program Documentation  
4.3.1. A program must contain the following head comment block:

 /***************************************************
  Program Name  :
  Module  :
  Function Tree : identifies which part of the function menu tree it is called (for ASP)
  Functionality : describes the functionality provided by the program
  Parameter List : (for Components)
  Return Codes : (for Components)
  Remarks :
 ******************************************************/

4.3.2.The program should have sufficient documentation to explain different sections of the program.

4.4 Programming Style
 Provide guidelines to standardize programming style in term of file, directory, class, variable, web  control naming, constant, etc.  This would help to ease program readable and maintenance.

4.4.1. File Naming
In general, file name uses the prefix of module and followed by underscore. For example: adm_, oe_, bl_,… Files for common module do not have such prefix.

Namespace
The recommended name space for StarLight framework classes is, StarLight, followed by project name and the class name, e.g. StarLight.CommonApp.CmFunc

As for other customized classes, the namespace for both web form and class should follow the directory structure of the file. Between root directory and sub directory separated by full stop. First character for each directory name is in upper case.

Server Control Naming
Each web control must have prefix as defined below. First character for each subsequent word is in capital letter.

Controls Prefix 
Data Connector dcn_ 
Data Adapter dap_ 
Data Set dst_ 
Data View dvw_ 
Data Table dtb_ 
Data Row drw_ 
Data Column dcl_ 
TextBox txt_ 
Label lbl_ 
ListBox lbx_ 
Button (for all button types) btn_ 
Drop Down List drp_ 
Data Grid dgd_ 
Data List dls_ 
Check Box chk_ 
Check Box List cbl_ 
Radio Button rbt_ 
Radio Button List rbl_ 
Image img_ 
Panel pnl_ 
Place Holder phd_ 
Calendar cal_ 
Table tbl_ 
Validator Require Field vrf_ 
Validator Range vrg_ 
Validator Regular Expression vre_ 
Validator Custom vcu_ 
Validator Compare vcp_ 
Validator Summary vsm_  

Class property/method
First character of each word is in capital letter.
For example: Conn, SQLSelect(), GetUserID().

Local variable, parameters and query string
First character of first word is in lower case. First character of the subsequent word is in upper case. For example: sqlText, userContactNo.

Session variables
For common session that is defined in GlobalUnit must have GB_ prefix in front. First character of each subsequent word is in capital letter. For example: GB_AppRoot, GB_SysUserID.
For each module must follow the module prefix in front and first character of each subsequest word is in capital letter. For example: OE_TermEffDate.

Constant/Enum
Any declaration of constant variable or Enum data structure must be in capital letter for all of the letters.

Maximum number of lines for function/file
In order for the program to be more readable and easy to maintain, maximum number of lines of codes for function is restricted to 100 – 150 lines.  The maximum lines of codes for a file/class is 500 – 700.

Comments on codes
Comments for method is on the top of the method. The escape character used is ‘///’. It will generate and xml format of comment. This is used to automate the generation of code comment report in html format.

Comments for particular line of code use ‘//’ escape character.

For long description of codes use ‘/*… */’. Minimal use of such escape character as it can be implemented by using ‘///’.


Xml file coding standard
For all node name and attribute, use title case, similar to class public property and method naming.
Example:
 <XmlNode FirstAttribute="Value String" SecondAttribute="string value">
 </XmlNode>

Try to reduce the number of nodes.  If a field is not repetitive, store the field as a attribute instead of creating a new node for it.
Example:
 (Recommended)
 <DataSource TableName="US_FUNCROLE"></DataSource>
 
 vs

 (Not Recommended)
 <DataSource>
  <TableName>US_FUNCROLE</TableName>
 </DataSource>


Use attribute instead of node value as far as possible.  Unless the value is multiple line or very long.  For example,
 <BillInfo AcctNo="012345"></BillInfo>

 <AddressInfo>
  1 HillCrest Road
  STA
  Singapore 288893
 </AddressInfo>


For Yes/No fields, we will use Y/N (upper case) to store the value.  For example,
<ValidationInfo CheckNull="Y" CheckRange="Y" CheckFormat="N"> </ValidationInfo>

转载于:https://www.cnblogs.com/RobotTech/archive/2007/05/28/762316.html

“近年来程序设计领域最好的一本书。”——Larry O’Brien, Software Development Times, July 29, 2015 Using a simple computational task (term frequency) to illustrate different programming styles, Exercises in Programming Style helps readers understand the various ways of writing programs and designing systems. It is designed to be used in conjunction with code provided on an online repository. The book complements and explains the raw code in a way that is accessible to anyone who regularly practices the art of programming. The book can also be used in advanced programming courses in computer science and software engineering programs. The book contains 33 different styles for writing the term frequency task. The styles are grouped into nine categories: historical, basic, function composition, objects and object interactions, reflection and metaprogramming, adversity, data-centric, concurrency, and interactivity. The author verbalizes the constraints in each style and explains the example programs. Each chapter first presents the constraints of the style, next shows an example program, and then gives a detailed explanation of the code. Most chapters also have sections focusing on the use of the style in systems design as well as sections describing the historical context in which the programming style emerged. Cristina Videira Lopes,加州大学欧文分校信息学教授,致力于大规模数据和系统的软件工程研究。她是施乐帕洛阿尔托研究中心的创始成员,还研发并维护着一个搜索引擎,为基于OpenSimulator的虚拟世界提供帮助。
“近年来程序设计领域最好的一本书。”——Larry O’Brien, Software Development Times, July 29, 2015 Using a simple computational task (term frequency) to illustrate different programming styles, Exercises in Programming Style helps readers understand the various ways of writing progr ams and designing systems. It is designed to be used in conjunction with code provided on an online repository. The book complements and explains the raw code in a way that is accessible to anyone who regularly practices the art of programming. The book can also be used in advanced programming courses in computer science and software engineering programs. The book contains 33 different styles for writing the term frequency task. The styles are grouped into nine categories: historical, basic, function composition, objects and object interactions, reflection and metaprogramming, adversity, data-centric, concurrency, and interactivity. The author verbalizes the constraints in each style and explains the example programs. Each chapter first presents the constraints of the style, next shows an example program, and then gives a detailed explanation of the code. Most chapters also have sections focusing on the use of the style in systems design as well as sections describing the historical context in which the programming style emerged. Cristina Videira Lopes,加州大学欧文分校信息学教授,致力于大规模数据和系统的软件工程研究。她是施乐帕洛阿尔托研究中心的创始成员,还研发并维护着一个搜索引擎,为基于OpenSimulator的虚拟世界提供帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值