The Elements of Programming Style

The Elements of Programming Style.pdf The ElementsThe Elements of Programming Style.pdf ofThe Elements of Programming Style.pdf Programming Style.pdf 立即下载

The Elements of Programming Style
Brian Kernighan, P. J. Plauger

Introduction
  1. Write clearly - don't be too clever.
Expression
  1. Say what you mean, simply and directly.
  2. Use library functions.
  3. Avoid temporary variables.
  4. Write clearly - don't sacrifice clarity for 'efficiency.'
  5. Let the machine do the dirty work.
  6. Replace repetitive expressions by calls to a common function.
  7. Parenthesize to avoid ambiguity.
  8. Choose variable names that won't be confused.
  9. Avoid the Fortran arithmetic IF.
  10. Avoid unnecessary branches.
  11. Use the good features of a language; avoid the bad ones.
  12. Don't use conditional branches as a substitute for a logical expression.
  13. Use the 'telephone test' for readability.
Control Structure
  1. Use DO-END and indenting to delimit groups of statements.
  2. Use IF-ELSE to emphasize that only one of two actions is to be performed.
  3. Use DO and DO-WHILE to emphasize the presence of loops.
  4. Make your programs read from top to bottom.
  5. Use IF, ELSE IF, ELSE IF, ELSE to implement multi-way branches.
  6. Use the fundamental control flow constructs.
  7. Write first in an easy-to-understand pseudo-language; then translate into whatever language you have to use.
  8. Avoid THEN-IF and null ELSE.
  9. Avoid ELSE GOTO and ELSE RETURN.
  10. Follow each decision as closely as possible with its associated action.
  11. Use data arrays to avoid repetitive control sequences.
  12. Choose a data representation that makes the program simple.
  13. Don't stop with your first draft.
Program Structure
  1. Modularize. Use subroutines.
  2. Make the coupling between modules visible.
  3. Each module should do one thing well.
  4. Make sure every module hides something.
  5. Let the data structure the program.
  6. Don't patch bad code - rewrite it.
  7. Write and test a big program in small pieces.
  8. Use recursive procedures for recursively-defined data structures.
Input and Output
  1. Test input for validity and plausibility.
  2. Make sure input cannot violate the limits of the program.
  3. Terminate input by end-of-file or marker, not by count.
  4. Identify bad input; recover if possible.
  5. Treat end of file conditions in a uniform manner.
  6. Make input easy to prepare and output self-explanatory.
  7. Use uniform input formats.
  8. Make input easy to proofread.
  9. Use free-form input when possible.
  10. Use self-identifying input. Allow defaults. Echo both on output.
  11. Localize input and output in subroutines.
Common Blunders
  1. Make sure all variables are initialized before use.
  2. Don't stop at one bug.
  3. Use debugging compilers.
  4. Initialize constants with DATA statements or INITIAL attributes; initialize variables with executable code.
  5. Watch out for off-by-one errors.
  6. Take care to branch the right way on equality.
  7. Avoid multiple exits from loops.
  8. Make sure your code 'does nothing' gracefully.
  9. Test programs at their boundary values.
  10. Program defensively.
  11. 10.0 times 0.1 is hardly ever 1.0.
  12. Don't compare floating point numbers just for equality.
Efficiency and Instrumentation
  1. Make it right before you make it faster.
  2. Keep it right when you make it faster.
  3. Make it clear before you make it faster.
  4. Don't sacrifice clarity for small gains in 'efficiency.'
  5. Let your compiler do the simple optimizations.
  6. Don't strain to re-use code; reorganize instead.
  7. Make sure special cases are truly special.
  8. Keep it simple to make it faster.
  9. Don't diddle code to make it faster - find a better algorithm.
  10. Instrument your programs. Measure before making 'efficiency' changes.
Documentation
  1. Make sure comments and code agree.
  2. Don't just echo the code with comments - make every comment count.
  3. Don't comment bad code - rewrite it.
  4. Use variable names that mean something.
  5. Use statement labels that mean something.
  6. Format a program to help the reader understand it.
  7. Indent to show the logical structure of a program.
  8. Document your data layouts.
  9. Don't over-comment.
The Elements of Programming Style (2nd edition) 牛人,老书 不多说了 论坛上没有pdf格式,上传给大家分享 立即下载

相关推荐

The Elements Of Programming Style 2ed(Kernighan,Plauger)

djvu 格式, 压缩包内附带阅读器, 以前无意中找到的, 上传以供分享 至于书本身, 会下的人想必都已清楚, 就不多说了

The Elements of Programming Style (编程风格的元素)读书总结

这是一本关于编程风格经典的老书了,一些经典的CS著作里面都提过此书,而且都是强烈推荐阅读,当初就是因为些书评价非常高,所以才想读的,不过很可惜,由于此书出版年月太早,而且书中使用的语言为fortran语言,所以已经停止印刷了。网上有pdf版,可以在这里下载(点击打开链接)。 虽然是用fortran语言写的,不过里面关于编程风格的每一条建议对于每一个程序员都还是很有帮助的。看的过程中,发现里面很多

xuzhezhaozhao的专栏 3017

Elements of Programming Interviews

Elements of Programming Interviews: The Insiders’ Guide Adnan Aziz Tsung-Hsien Lee Amit Prakash

Elements of Programming:追溯数学原理,探求编程的本质

《编程原本》(Elements of Programming)前言 本书将演绎方法应用于程序设计,讨论程序与保证它们能正确工作的抽象数学理论之间的联系。书中把反映这些理论的规程(speci.cation),基于这些理论写出的算...

cuad2192的博客 334

The Elements of Style 4th Edition 英文写作指南第4版 William Strunk Jr.

全英文版。写英文论文或者文章必备的指南。PDF有目录标签,相当好用。

The Elements of Programming Style 2nd edition

The Elements of Programming Style 2nd edition

The elements of programming style,好程序的要素

软件工程经验 本是Fortran语言时代的软件工程经验总结,感觉多数条目也适合使用任何语言开发项目。 条目 Write clearly - don’t be too clever 清晰是最重要的,不要耍聪明 Say waht you mean, simply and directly 词要达意 Use library functions 不要重造轮子 Avoid temprorary variables 避免滥用临时变量 Write clearly - don’t sacrifice clarity fo

weixin_42849849的博客 444

基于STM32的智能工业机器人臂控制系统

工业机器人臂是智能制造的核心组件,广泛应用于装配、焊接、搬运等任务。基于STM32微控制器的机器人臂控制系统,通过集成伺服电机驱动、运动规划算法和实时通信功能,实现对多轴机械臂的精确控制与路径规划。本设计通过STM32实现了一套智能工业机器人臂控制系统,集成了高效的运动规划算法和实时控制功能。机器人臂系统根据输入的目标位置(如工件坐标),通过运动学计算生成动作轨迹,利用伺服电机驱动器控制关节运动。该系统广泛应用于工业自动化场景,如汽车制造中的零件装配、电子产品生产中的元件焊接以及物流系统中的物料搬运。

stm32d1219的博客 2573

The Elements of Programming Style 读书总结

(The Elements Of Programming Style, Second Endition, Kernigan and Plauger) 这是一本关于编程风格经典的老书了,一些经典的CS著作里面都提过此书,而且都是强烈推荐阅读,当初就是因为些书评价非常高,所以才想读的,不过很可惜,由于此书出版年月太早,而且书中使用的语言为fortran语言,所以已经停止印刷了。网上有pdf版,可

jinvmen的博客 1293

SuccessFactors入门篇

SuccessFactors入门篇—— Employee Central(一)最近通过一个月左右的学习,拿到了SF EC(SuccessFactors Employee Central )模块SAP认证,所以打算把自己学习SF的整个过程以及相关资料和大家分享一下,相互切磋,共同进步。Employee Central简单了解Employee Central简单了解新的改变功能快捷键合理的创建标题,有...

qq_42288853的博客 1万+

注册电气工程师详细教材

注册电气工程师详细教材

qq_40844444的博客 4263

The Elements of Programming Style 编程风格要素 中文英文中英对照

下面的程序风格规则提炼自Brian Kernighan和P. J. Plauger的经典著作《The Elements of Programming Style》(由McGraw Hill出版)。由于原书出版较早并主要针对Fortran语言,本文仅提炼适用于当今主流编程语言的风格要素。 ——Clive Studio 1.Write clearly - don't be too clever.要...

weixin_30693183的博客 457

机器学习预测土壤养分:从电导率、pH到随机森林与神经网络的农业实践

在智慧农业与精准农业领域,机器学习已成为处理复杂农业数据、挖掘潜在规律的关键技术。其核心原理在于通过算法从多维数据中自动学习特征与目标变量之间的映射关系,尤其擅长捕捉非线性关联。这项技术的核心价值在于能够将传统上依赖昂贵、耗时实验室分析的问题(如土壤养分检测),转化为基于易获取传感器数据(如电导率、pH值)的快速、低成本预测任务,为农业生产的实时决策与资源优化提供了全新可能。其典型应用场景包括作物生长监测、产量预测以及精准施肥管理等。本文聚焦于利用随机森林和神经网络等回归算法,构建通过土壤物理参数预测氮磷钾

weixin_33693070的博客 671

【转载】The Elements of Programming Style之代码风格金科玉律

原始日期: 2017-02-06 16:20 《The Elements of Programming Style 》是一本很古老的书。尽管 Fortran 我们不太使用,尽管新奇的语言层出不穷,但这些,30 年的岁月依旧无法掩盖其中的真知灼见。英文版的 google一下到处有。把代码写清楚,别耍小聪明。想干什么,讲的简单点、直接点。只要有可能,使用库函数。避免使...

weixin_30457881的博客 86

基于Arduino的智能光源调节系统设计

本文设计了一个基于Arduino的智能光源调节系统,通过光敏传感器检测环境光照强度并自动调节光源亮度,同时提供了手动控制和远程控制功能。系统采用Wi-Fi模块实现远程控制,用户可以通过手机或网页进行操作。未来,随着智能家居技术的进一步发展,系统可以加入更多智能化的功能,如语音控制、自动场景切换等,为用户提供更便捷的使用体验。同时,随着5G、物联网技术的普及,系统的远程控制能力将更加完善,能够实现更加精准的控制和更高效的数据传输。

2201_76125393的博客 753

芯擎SEC1000芯片参数详细介绍

随着龙鹰一号的不断进化和应用,未来的智能座舱将不仅仅是显示和控制的集成,更是人与车之间的一种默契和无缝交互的体现。在汽车行业迈向智能化和电动化的浪潮中,座舱已不仅仅是一个驾驶者的操作空间,而是逐渐演变为一个集娱乐、信息、控制于一体的智能交互平台。今天的汽车不仅需要强劲的动力和炫酷的外观,更需要一颗强大而智能的“心脏”来支撑复杂的座舱体验和安全驾驶需求。想象一下,未来的汽车不再仅仅是交通工具,它将成为你的移动私人管家,了解你的习惯,甚至提前预测你的需求。让我们一起走进龙鹰一号的世界,探索智能座舱的无限可能!

weixin_43199439的博客 1725

The elements of programming style

Write clearly - don't be too clever  清晰是最重要的,不要耍聪明 Say waht you mean, simply and directly 词要达意 Use library functions 不要重造轮子 Avoid temprorary variables 避免滥用临时变量 Write clearly - don't sacrifice clar

amao992的专栏 957

s8654

The official Snapdragon Ride SX 4.0 development board provides standardized hardware support for the secondary development and functional verification of the s8654 platform.

qq_39257814的博客 6835
上一篇: graphics and games资源网站
下一篇: 齐次空间的裁剪
softwarekid
博客等级 码龄18年 6粉丝 3原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值