Naming Variables-From "Code Complete"
来源:互联网 发布:怎么找回淘宝店铺 编辑:程序博客网 时间:2024/06/06 08:41
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?
- Naming Variables-From "Code Complete"
- Code Complete --- (Note3 Variables)
- the thinker of code complete -- general issues in using variables
- 关于设计问题的总结-from 《code complete 2》
- 《CODE COMPLETE》
- Code Complete
- complete code
- 《Code Complete》
- Naming Things in Code
- Naming Things in Code
- Code Complete 2nd
- 本好书--code complete
- code complete(1)
- code complete(2)
- code complete(3)
- 阅读Code Complete
- complete exercise source code
- Code Complete(持续更新)
- NYOJ另一种阶乘
- Code Vs 1039 数的划分(推广为变型)11.4版本
- Anagrams
- linux学习之十---vfork()&fork()函数
- curl命令行工具---常用方法总结
- Naming Variables-From "Code Complete"
- oracle merge 误区
- 根据简历预测自己的面试问题
- css BFC粗浅应用
- 一致性 hash 算法( consistent hashing )
- QT项目升级(QT4到QT)
- Java中常用缓存Cache机制的实现
- Linux内核中的内存屏障
- 利用统计方法求π(PI),并可视化显示求解过程(C++&&OpenCV)