Data Names

1. Express exact meaning.
2. As short as possible.

Naming Loop Indexes
In common, we can use the names such as i,j and k; but when loop is long and complex, we should use a meaningful name like recordCount.

Naming Status Variables
Think of a better name than flag for status variables.

Naming Temporary Vriables
In one way or another, most of the variables in your program are temporary.  Calling a few of them temporary may indicate that you aren't sure of their real purpose. So also give it a meaningful name.

Naming Boolean Variable
Give boolean variables names that imply True of False, such as Is....
Use positive boolean variable names.

Naming Enumerated Types
Give a group prefix to these variables.

Conventions for names
1. Differentiate between variable and routine name.
variable name is begin with lower case and routine name with upper case.
2. Differentiate bwtween clases and objects
Differentiating them via initial Capitalization.
3. Identify global variables
use g_ prefix.
4. Identify member variables.
use m_ prefix.
5. Identify type definitions
prefix the type names before the variable.
6. Format names to enhance readability.
Two common techiniques for increasing readability are using capitalization and spacing characters to separate words.

Comments on Abbreviations
1. Don't abbreviate by removing one characters from a word.
2. Abbreviate consistenly.
3. Create names that you can pronounce.
4. Avoid combinations that result in mispronunciation.
5. Use a thesaurus to resolve naming collisions.
6. Document extremely short names with translation tables in the code.
7. Document all abbreviations in a project-level "Standard Abbreviations" document.

Kinds of Names to Avoid
1. Avoid misleading names or abbreviations.
2. Avoid names with similar meanings.
3. Avoid variables with different meanings but similar names.
4. Avoid names that sound similar.
5. Avoid numberals in names.
6. Avoid misspelled words in names.
7. Avoid words that are commonly misspelled in English.
8. Avoid names containing hard-to-read characters.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值