Programming Style
来源:互联网 发布:阿里云centos图形界面 编辑:程序博客网 时间:2024/05/17 21:47
Names
Precept:
Always name your classes, variables and functions with the greatest care, and explain them thoroughly.
Guidelines:
- Keep the names simple for variables which are used only briefly and locally;For a controlling a for loop, it is often possible to find a short but meaningful word that better describes the use of the variable.
- Avoid deliberate misspelling and meaningless suffixes to obtain different names.*
- Be careful int the use of the letter”l”(small ell), “O”(capital oh), and “0”(zero). both “I” and “O” should never be used alone as names.
Documentation and Format
Precept:
Keep your documentation concise but descriptive.
Guidelines:
- Place a prologue at the beginning of each function including:
(a) Identification (programmer’s name, date, version number).
(b) Statement of the purpose of the function and algorithm used.
(c) The changes the function makes and what data it use.
(d) Reference to further documentation external to the program. - When each variable, constant, or class is declared, explain that what it is and how it is used. BETTER still, make this information evident from the name.
- For those significant section(Paragraph or Function ) of the program, it is essential to have a comment stating briefly its purpose or action.
- Avoid comments that parrot what the code does, such as
count ++; //Increase counter by 1.
or that are meaningless jargon, such as// Horse string length into correctitude.
- Explain any statement that employs a trick or whose meaning is unclear. BETTER still, avoid such statements.
- The code itself should explain how the program works. The documentation should explain why it works and what it does.
- Whenever a program is modified, be sure that the documentation is correspondingly modified.
Precept
The reading time for programs is much more than the writing time. Make reading easy to do.
Refinement and Modularity
Precept:
1. Don’t lose sight of the forest for its trees.
2. Use classes to model the fundamental concepts of the program.
3. Each lass or function should hide something
** Middle-level managers in a large company do not pass on everything they receive form their departments to their superior; they summarize, collate, and weed out the information, handle many requests themselves, and send on only what is needed at the upper levels.
Guidelines about parameters
- Input Parameters
- Output Parameters
- Inout parameters
- Local Variables
- Global Variablesf
- Programming style
- Programming Style
- Java Programming Style Guidelines
- C & C++ Programming Style Guidlines
- A Programming Style for Java
- The Elements of Programming Style
- The Elements of Programming Style
- The Elements of Programming Style
- The Elements of Programming Style
- The Elements of Programming Style
- The Elements of Programming Style
- The elements of programming style
- The Elements of Programming Style
- The Elements of Programming Style
- The Elements of Programming Style
- Elements of Programming Style -- The C++ Style Guide
- Elements of Programming Style -- The C++ Style Guide
- JavaScript Tricks And Good Programming Style
- iOS安全攻防(二十三):Objective-C代码混淆
- Uiautomator通过CTSHelper类查看完美报告--小白上手
- Codeforces 732B Cormen — The Best Friend Of a Man【贪心】
- 构造函数,拷贝构造函数,析构函数,赋值运算符重载
- Spring使用jdbcTemplate
- Programming Style
- RecyclerView局部刷新的坑
- 设置tomcat的用户名密码
- java--swing 组件(4)
- Git常用命令实践总结
- jquery全选,jquery全不选,jquery反选
- 总结七条助你成为Linux高手的超棒忠告
- 机器学习小组知识点5:随机梯度下降(SGD)以及与批量梯度下降(BGD)的比较
- [c++简单小游戏]东搞西搞第三弹——伪的不能再伪的字符游戏库。。。