Naming Variables-From "Code Complete"

Naming Variables Checklist:

1. General Naming Considerations:

1) Does the name fully and accurately describe what the variable represents?

2) Does the name refer to the real-world problem rather than to the programming -language solution ?

3) is the name long enough that you don't have to puzzle it out 

4) are computed-value qualifiers,if any, at the end of the name?


2. Naming Specific Kinds of Data

1) Are loop index names meaningful (something other than i,j,k if the loop is more than one or two lines long or is nested?)

2) have all 'temporary 'variables been renamed to something more meaningful ?

3) are Boolean variables named so that their meanings when they're TRUE are clear?

4) do enumerated-type names include a prefix or suffix that indicates the category -for example , Color_for Color_Red,Color_Green and so on ?

5) are named constants named for the abstract entities they represent rather than the numbers they refer to ?


3. Naming Conventions 

1) Does the convention distinguish among local,class ,global data ?

2) does the convention distinguish among type names, named constants ,enumerated types and variables ?

3) is the conversion as compatible as possible with standard convention for the language ?

4) are names formatted for readability?


4. Short Names:

1) Does the code use long names (unless it's necessary  to use short ones)?

2) does the code avoid abbreviations that save ONLY one character ?

3) are all Words abbreviated consistently ?

4) are the name pronounceable?

5) are namespace that could be mispronounced avoided?

6) are short names documented in translation table?


5. Common Naming Problems : Have you avoided

1) names that are misleading 

2) names with similar meanings

3) names that are different by ONLY one or two characters

4) names that are use numerals?

5) names intentionally misspelled to make them shorter 

6) names that are commonly misspelled in English 

7) names that conflict with standard library-routine names or with predefined  variable names?

8) totally arbitrary names?

9) hard to read characters?


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值