The Art of Readable Code

Dustin Boswell

出版时间

2011-10-08

ISBN

9780596802295

评分

★★★★★

标签

编程

书籍介绍
这是一本写给日常写代码的人的小书,不谈架构宏大叙事,只关心你坐下敲键盘时那些具体而微的判断。作者的核心主张朴素却反直觉:编程的首要任务不是教计算机做什么,而是向同事——以及六个月后的自己——解释清楚。全书由大量短小、可立即上手的小技巧堆叠而成:如何为变量挑选“信息密度高”的名字、如何组织循环与条件、如何写简短的注释、如何识别“一次干太多事”的代码。读者反馈高度一致地指向它的“轻”:一晚上能读完,漫画可爱、排版清爽,适合碎片时间翻查。但也有人直言内容“无甚新意”。正因如此,它的价值不在理论深度,而在把零散经验提炼成可复用的清单,让注重细节、追求利人利己的开发者快速获得可执行的方法。
作者简介
Dustin Boswell Although raised in the circus, Dustin Boswell realized early on that he was better at computers than at acrobatics. Dustin received his B.S. from CalTech, where he got hooked on Computer Science, and then went to UC San Diego for his Master's Degree. He worked at Google for five years, on a variety of projects including web crawling infrastructure. Dustin is now an internet startup junkie who spends his free time hiking the Santa Monica mountains and being a new dad. Trevor Foucher has been shipping software projects for over 10 years, including Windows 2000 and OneCare at Microsoft, and Webmaster Tools at Google. He's been an individual contributor, manager, and tech lead. His goal is to make code more readable and reliable.
AI导读
核心看点
  • 提出可读性基本定理:代码应最小化他人理解时间
  • 提供变量命名、循环组织等实用技巧,提升代码清晰度
  • 强调测试代码也需可读,便于后续维护与修改
读者共识
  • 内容短小精悍,案例源自实战,阅读体验轻松愉快
  • 被公认为讲解代码可读性最优秀、最生动的入门书籍
  • 虽深度不及大部头,但细节建议极具价值,物超所值
精彩摘录
  • "找到更有表现力的词 send -> deliver, dispatch, announce, distribute, route find -> search, extract, locate, recover start -> launch, create, begin, open make -> create, set up, build, generate, compose, add, new"
  • "Names like i, j, iter, and it are commonly used as indices and loop iterators. Even though these names are generic, they’re understood to mean “I am an iterator.” (In fact, if you used one of these names for some other purpose, it would be confusing—so don’t do that!) But sometimes there are better "
  • "The goal of this book is help you make your code better."
  • "Keeping Your Codebase Small"
  • "Finding More "Colorful" Words"
  • "Values with Units"
  • "Test code should be readable so that other coders are comfortable changing or adding tests."
  • "Creating the Minimal Test Statement"
目录
Dustin Boswell turned to computer programming at a very early age. After receiving his master's degree he joined Google, where he spends his working hours on web crawling and AdSense Ads.
Trevor Foucher has been shipping software projects for over 10 years, including Windows 2000 and OneCare at Microsoft, and Webmaster Tools at Google. He's been an individual contributor, manager, and tech lead. His goal is to make code more readable and reliable.
用户评论
这本书的Further Reading里列出来的书里有Code Complete, Clean Code, Refactor, The Practice of Programming, 如果读过其中的任何一本, 都会觉得这本书没有什么新的内容 ... 嗯 每一节开头的漫画很赞 ... 最后一章是一个从烂到赞的重构过程, 嗯, 读起来很晕 ...
漂亮的出版社、封面、书名、以及插图,所触基本为函数级别或以下的代码,清晰易懂,可惜鲜见前人肩膀之后更新或更深的阐述,Further Reading值得细看。
篇幅小内容有价值适合上下班阅读。
轻松愉快
里面还提到了对测试代码的可读性介绍,书里的漫画配得不错。
命名备注这些经常在写代码里被忽略的东西确实很重要。以前总以为代码行数少就很自豪,工作了发现代码写的让人看懂让自己在之后看懂更重要。这书很好读对很多基本的概念解释地不错。同事写的必须给个满星👍
这本书标注了六七年终于这星期抽空看掉了,每天一到两小时30页,一周看完。需要编程经验,不适合新手。最后的推荐阅读书目很有意思,基本是软件工程必读著作,还主动把自己和 Clean Code 对比了一下。看完这个 Clean Code 基本不用看 - Clean Code 使用的是 Java 所以多出来的部分是 error handling 和 cocurrency 的东西。而本书针对的是泛化的编程语言,例子里用得最多的是 C++,其次是 JavaScript 和 Python。
Uncle Bob 的经典之作
很有实践性的经验之谈,看完可以直接看Martin Fowler的Refactoring。
It deserves to read again
下载
收藏