- Say what you mean, simply and directly.
- Use the ``telephone test'' for readability.
- Write clearly - don't be too clever.
- Don't use conditional expressions as a substitute for a logical expression.
- Parenthesize to avoid ambiguity.
- Each time you make a test, do something.
- Follow each decision as closely as possible with its associated action.
- Use the good features of a language; avoid the bad ones.
- Capture regularity in control flow, irregularity in data.
- Each module should do one thing well.
- Make sure comments and code agree.
- Don't just echo the code with comments - make every comment count.
- Don't comment bad code - rewrite it.
- Use symbolic constants for magic numbers.
- Watch out for side effects and order of evaluation.
- Macros are not functions.
- Watch out for off-by-one errors.
- Test programs at their boundaries.
- Program defensively.
- Make sure input cannot violate the limits of the program.
- Make it right before you make it faster.
- Keep it right when you make it faster.
- Don't sacrifice clarity for small gains in ``efficiency.''
- Don't stop with your first draft.
[From The Elements of Programming Style, Kernighan & Plauger, McGraw-Hill, 1978]
Note: this book is still well worth reading- even though most of the examples are in languages that you probably haven't heard of, the principles are universal. -DJE
分享到:
相关推荐
Brian Kernighan & Dennis Ritchie:The C Programming Language.epub
djvu 格式, 压缩包内附带阅读器, 以前无意中找到的, 上传以供分享 至于书本身, 会下的人想必都已清楚, 就不多说了
本书原著 即为C语言的设计者之一Dennis M.Ritchie和著名的计算机科学家Brian W.Kernighan合著的 一本介绍C语言的权威经典著作。我们现在见到的大量论述C语言程序设计的教材和专著均以 此书为蓝本。原著第1版中...
Brian Kernighan
The most classic Uinx ... work of father of Unix, Brian W. Kernighan. For remarking of this book, please refer to: http://www.amazon.com/Unix-Programming-Environment-Prentice-Hall-Software/dp/013937681X
[C程序设计语言].The.C.Programming.Language By Brian W. Kernighan and Dennis M. Ritchie. 第二版 中文
C程序设计语言(第2版.新版)(The.Programming.Language).Brian.W.Kernighan.扫描版
本书原著 即为C语言的设计者之一Dennis M.Ritchie和著名的计算机科学家Brian W.Kernighan合著的 一本介绍C语言的权威经典著作。我们现在见到的大量论述C语言程序设计的教材和专著均以 此书为蓝本。原著第1版中...
[英文]介绍C语言而非编程方法和设计,内容有:入门例子、类型/操作符/表达式、控制流、函数/程序结构、指针与数组、结构体、输入与输出、Unix系统接口、附录A:参考手册、附录B:标准库。
[C程序设计语言 第2版 新版 ] Brian W Kernighan等 扫描版
The Unix Programming Environment is a book written by Brian W. Kernighan and Rob Pike, both of Bell Labs. It is considered an important and early document of the Unix operating system. Often ...
【pdf】The Practice Of Programming(Brian W.Kernighan, Rob Pike) 程序设计实践
牛人,老书 不多说了 论坛上没有pdf格式,上传给大家分享
本答案为经典的c圣经《c程序设计语言》非官方英文的配套答案,所列页码均为英文版的。本想整理为pdf格式,考虑到程序能直接运行,最终还是决定为网页格式,希望能给大家的学习带来帮助!感谢给出答案的程序工程师,...
本书是Brian W. Kernighan和Rob Pike合著的最新力作。本书从排错、测试、性能、可移植性、设计、界面、风格和记法等方面,讨论了程序设计中实际的、又是非常深刻和具有广泛意义的思想、技术和方法,它的翻译出版将...
tcpl:我对Brian Kernighan和Dennis Ritchie的“ The C Programming Language”的尝试
本书是Brian W. Kernighan和Rob Pike合著的最新力作。本书从排错、测试、性能、可移植性、设计、界面、风格和记法等方面,讨论了程序设计中实际的、又是非常深刻和具有广泛意义的思想、技术和方法,它的翻译出版将...
C程序设计语言(第2版*新版)(美)Brian W.Kernighan 、Dennis M.Ritchie。高清!
他参加了UNIX系统、C语言、AWK语言和许多其他系统的开发,同时出版了许多在计算机领域具有影响的著作,如《The Elements of Programming Style》、《The Practice of Programming》、《The UNIX Programming ...
C程序设计语言_中文第2版_Brian W.Kernighan