- 前言
- 致谢
- 什么是自表达代码
-
第I部分 可读性
-
第一章 低可读性之殇
- 1.1 恼人的Bug
- 1.2 难以理解
- 1.3 难以扩展或变更
- 1.4 容易做入Bug
- 1.5 难以重构
-
第二章 追本溯源
- 2.1 英语能力
- 2.2 编程语言语法
- 2.3 命名
- 2.4 架构
- 2.5 结构
- 2.6 注释
- 2.7 风格
- 2.8 限制性规则
- 2.9 管理人员的误导
-
第三章 一次可读性改进体验
- 3.1 单词
- 3.2 风格
- 3.3 算法
- 3.4 修订
-
第一章 低可读性之殇
-
第II部分 可读性改进
-
第四章 正确的使用英语
- 4.1 常见错误
- 4.2 前缀、后缀
- 4.3 成对词
- 4.4 缩写
- 4.5 词性
- 4.6 语法
- 4.7 时态
- 4.8 消极表达
-
第五章 利用编程语言特性
- 5.1 注解
- 5.2 异常
- 5.3 反射
- 5.4 泛型
- 5.5 Lambda表达式
-
第六章 命名的改进
- 6.1 包的命名
- 6.2 接口的命名
- 6.3 类的命名
- 6.4 枚举的命名
- 6.5 注解的命名
- 6.6 方法的命名
- 6.7 变量的命名
- 6.8 常量的命名
- 6.9 同位语
- 6.10 关键词
- 6.11 其他改进
-
第七章 架构的改进
- 7.1 分层与分包
- 7.2 内部类、内部接口及内部枚举
- 7.3 匿名类
- 7.4 关系
- 7.5 有限取值范围
- 7.6 防止类爆炸
- 7.7 抽象
- 7.8 职责
-
第八章 结构的改进
- 8.1 缩短长方法
- 8.2 减少参数个数
- 8.3 减少嵌套层数
- 8.4 消除重复和类似
- 8.5 解耦合
- 8.6 减少多因素影响
- 8.7 避免强制类型转换
- 8.8 缩短长判定
- 8.9 去除无用代码
- 8.10 去除临时变量
-
第九章 注释的改进
- 9.1 Java Doc
- 9.2 FIXME, TODO, XXX
- 9.3 版权
- 9.4 类说明
- 9.5 方法的说明
- 9.6 处理的注释
- 9.7 注释掉的代码
-
第十章 风格的改进
- 10.1 缩进
- 10.2 对齐
- 10.3 空格
- 10.4 代码区域
- 10.5 行长与Tab
- 10.6 换行
- 10.7 括号
- 10.8 长度与深度
-
第十一章 脚本的改进
- 11.1 面向对象的JavaScript
- 11.2 HTML
- 11.3 JSP
- 11.4 SQL
- 11.5 其他脚本
-
第十二章 配置文件的改进
- 12.1 XML
- 12.2 JSON
- 12.3 属性文件
- 12.4 Yaml
- 12.5 CSS
-
第十三章 符号的改进
- 13.1 点
- 13.2 逻辑运算
- 13.3 运算符号
- 13.4 引号
- 13.5 字符串参数
-
第十四章 算法的改进
- 14.1 递归调用
- 14.2 数据结构调整
- 14.3 应用领域特定语言
- 14.4 应用设计模式
- 14.5 用单线程替代多线程
-
第十五章 测试代码的可读性
- 15.1 断言
- 15.2 测试用例
- 15.3 测试夹具
- 15.4 测试代码的稳定性
-
第十六章 其他改进
- 16.1 文件与文件夹
- 16.2 URL
- 16.3 动态编程语言
- 16.4 混合编程
- 16.5 Log的记录
- 16.6 版本履历
-
第四章 正确的使用英语
-
第III部分 可读性探索
-
第十七章 IDE的帮助
- 17.1 自动格式化
- 17.2 拼写检查
- 17.3 代码审查
- 17.4 自动完成
-
第十八章 代码复查
- 18.1 机器的工作
- 18.2 速读
- 18.3 代码的5S
- 18.4 编码约定
- 18.5 代码复查的误区
-
第十九章 遗留系统的改善
- 19.1 确保先有合适的测试
- 19.2 从简单的地方入手
- 19.3 局部改善
- 19.4 结构性改善
-
第二十章 演进式设计
- 20.1 从第1行开始保持可读性
- 20.2 保持代码整洁
- 20.3 够用就好
- 20.4 考虑调用时的样子
- 20.5 使用第三方库
- 20.6 养成习惯
-
第十七章 IDE的帮助
- 附录I 常用成对词表
- 附录II 常用缩写表
- 附录III 常见用错的单词
自表达代码
书写可读代码之道
About
About the Book
代码可读性经常的困惑程序员。如何才能够书写出高可读性的代码呢?
本书将引领你从各个角度对代码的可读性进行提升。并分析造成代码可读性差的原因。
本书有大量丰富的实例给读者以更为直观生动的方式讲解提高代码可读性的方法。
代码可读性是代码内在质量的一个重要参考指标,无法书写高可读性的代码则成为降低代码内部质量的一个制约因素。
Author
About the Author
王洪亮
Speaks both of Chinese, Japanese and English.
Translations
Translations
Languages
Contents
Table of Contents
Get the free sample chapters
Click the buttons to get the free sample in PDF or EPUB, or read the sample online here
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Write and Publish on Leanpub
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.