注册 | 登录读书好,好读书,读好书!
读书网-DuShu.com
当前位置: 首页出版图书科学技术计算机/网络软件与程序设计代码整洁之道(英文版)

代码整洁之道(英文版)

代码整洁之道(英文版)

定 价:¥109.00

作 者: [美] 罗伯特·C.马丁 著
出版社: 人民邮电出版社
丛编项:
标 签: 暂缺

购买这本书可以去


ISBN: 9787115557582 出版时间: 2021-03-01 包装: 平装
开本: 16开 页数: 411 字数:  

内容简介

  软件质量,不但依赖架构和项目管理,而且与代码质量紧密相关。这一点,无论是敏捷开发流派还是传统开发流派,都不得不承认。本书提出一种观点:代码质量与其整洁度成正比。干净的代码,既在质量上较为可靠,也为后期维护、升级奠定了良好基础。作为编程领域的佼佼者,本书作者给出了一系列行之有效的整洁代码操作实践。这些实践在本书中体现为一条条规则(或称“启示”),并辅以来自实际项目的正、反两面的范例。只要遵循这些规则,就能编写出干净的代码,从而有效提升代码质量。本书阅读对象为有志于改善代码质量的程序员和技术经理。书中介绍的规则均来自作者多年的实践经验,涵盖从命名到重构的多个编程方面,虽为一家之言,然诚有可资借鉴的价值。

作者简介

  [美] 罗伯特.C. 马丁(Robert C. Martin):软件开发大师,设计模式和敏捷开发先驱,敏捷联盟首任主席,C++ Report前主编,被后辈程序员尊称为“Bob大叔”。20世纪70年代初成为职业程序员,后创办Object Mentor公司并任总裁。Martin还是一名多产的作家,至今已发表数百篇文章、论文和博客文章。除本书外,还著有《代码整洁之道:程序员的职业素养》《敏捷软件开发:原则、模式和实践》《UML:Java程序员指南》等。

图书目录

Chapter 1: Clean Code / 整洁代码 1
There Will Be Code / 要有代码 2
Bad Code / 糟糕的代码 3
The Total Cost of Owning a Mess / 混乱的代价 4
Schools of Thought / 思想流派 12
We Are Authors / 我们是作者 13
The Boy Scout Rule / 童子军军规 14
Prequel and Principles / 前传与原则 15
Conclusion / 小结 15
Bibliography / 文献 15
Chapter 2: Meaningful Names / 有意义的命名 17
Introduction / 介绍 17
Use Intention-Revealing Names / 名副其实 18
Avoid Disinformation / 避免误导 19
Make Meaningful Distinctions / 做有意义的区分 20
Use Pronounceable Names / 使用读得出来的名称 21
Use Searchable Names / 使用可搜索的名称 22
Avoid Encodings / 避免使用编码 23
Avoid Mental Mapping / 避免思维映射 25
Class Names / 类名 25
Method Names / 方法名 25
Don’t Be Cute / 别抖机灵 26
Pick One Word per Concept / 每个概念对应一个词 26
Don’t Pun / 别用双关语 26
Use Solution Domain Names / 使用解决方案领域名称 27
Use Problem Domain Names / 使用源自所涉问题领域的名称 27
Add Meaningful Context / 添加有意义的语境 27
Don’t Add Gratuitous Context / 不要添加没用的语境 29
Final Words / 最后的话 30
Chapter 3: Functions / 函数 31
Small! / 短小 34
Do One Thing 只做一件事 35
One Level of Abstraction per Function / 每个函数一个抽象层级 36
Switch Statements / switch 语句 37
Use Descriptive Names / 使用具有描述性的名称 39
Function Arguments / 函数参数 40
Have No Side Effects / 无副作用 44
Command Query Separation / 分隔指令与询问 45
Prefer Exceptions to Returning Error Codes / 使用异常替代返回错误码 46
Don’t Repeat Yourself / 别重复自己 48
Structured Programming / 结构化编程 48
How Do You Write Functions Like This / 如何写出这样的函数 49
Conclusion / 小结 49
SetupTeardownIncluder / SetupTeardownIncluder 程序 50
Bibliography / 文献 52
Chapter 4: Comments / 注释 53
Comments Do Not Make Up for Bad Code /注释不能美化糟糕的代码 55
Explain Yourself in Code / 用代码来阐述 55
Good Comments / 好注释 55
Bad Comments / 坏注释 59
Bibliography / 文献 74
Chapter 5: Formatting/ 75
The Purpose of Formatting / 格式的目的 76
Vertical Formatting / 垂直格式 76
Horizontal Formatting / 横向格式 85
Team Rules / 团队规则 90
Uncle Bob’s Formatting Rules / “鲍勃大叔”的格式规则 90
Chapter 6: Objects and Data Structures / 对象和数据结构 93
Data Abstraction / 数据抽象 93
Data/Object Anti-Symmetry / 数据、对象的反对称性 95
The Law of Demeter / 得墨忒耳律 97
Data Transfer Objects / 数据传送对象 100
Conclusion / 小结 101
Bibliography / 文献 101
Chapter 7: Error Handling / 错误处理 103
Use Exceptions Rather Than Return Codes / 使用异常而非返回码 104
Write Your Try-Catch-Finally Statement First /
先写try-catch-finally 语句 105
Use Unchecked Exceptions / 使用未检异常 106
Provide Context with Exceptions / 给出异常发生的环境说明 107
Define Exception Classes in Terms of a Caller’s Needs /
依调用者需要定义异常类 107
Define the Normal Flow / 定义常规流程 109
Don’t Return Null / 别返回null 值 110
Don’t Pass Null / 别传递null 值 111
Conclusion / 小结 112
Bibliography / 文献 112
Chapter 8: Boundaries / 边界 113
Using Third-Party Code / 使用第三方代码 114
Exploring and Learning Boundaries / 浏览和学习边界 116
Learning log4j / 学习log4j 116
Learning Tests Are Better Than Free /
学习性测试的好处不只是免费 118
Using Code That Does Not Yet Exist / 使用尚不存在的代码 118
Clean Boundaries / 整洁的边界 120
Bibliography / 文献 120
Chapter 9: Unit Tests / 单元测试 121
The Three Laws of TDD / TDD 三定律 122
Keeping Tests Clean / 保持测试整洁 123
Clean Tests / 整洁的测试 124
One Assert per Test / 每个测试一个断言 130
F.I.R.S.T. 132
Conclusion / 小结 133
Bibliography / 文献 133
Chapter 10: Classes / 类 135
Class Organization / 类的组织 136
Classes Should Be Small! / 类应该短小 136
Organizing for Change / 为了修改而组织 147
Bibliography / 文献 151
Chapter 11: Systems / 系统 153
How Would You Build a City / 如何建造一个城市 154
Separate Constructing a System from Using It /
将系统的构造与使用分开 154
Scaling Up / 扩容 157
Java Proxies / Java 代理 161
Pure Java AOP Frameworks / 纯Java AOP 框架 163
AspectJ Aspects / AspectJ 的方面 166
Test Drive the System Architecture / 测试驱动系统架构 166
Optimize Decision Making / 优化决策 167
Use Standards Wisely, When They Add Demonstrable Value /
明智使用添加了可论证价值的标准 168
Systems Need Domain-Specific Languages /
系统需要领域特定语言 168
Conclusion / 小结 169
Bibliography / 文献 169
Chapter 12: Emergence / 迭进 171
Getting Clean via Emergent Design / 通过迭进设计达到整洁目的 171
Simple Design Rule 1: Runs All the Tests /
简单设计规则1:运行所有测试 172
Simple Design Rules 2–4: Refactoring / 简单设计规则2~4:重构 172
No Duplication / 不可重复 173
Expressive / 表达力 175
Minimal Classes and Methods / 尽可能少的类和方法 176
Conclusion / 小结 176
Bibliography / 文献 176
Chapter 13: Concurrency / 并发编程 177
Why Concurrency / 为什么要并发 178
Challenges / 挑战 180
Concurrency Defense Principles / 并发防御原则 180
Know Your Library / 了解Java 库 182
Know Your Execution Models / 了解执行模型 183
Beware Dependencies Between Synchronized Methods /
警惕同步方法之间的依赖 185
Keep Synchronized Sections Small / 保持同步区域微小 185
Writing Correct Shut-Down Code Is Hard /
很难编写正确的关闭代码 186
Testing Threaded Code / 测试线程代码 186
Conclusion / 小结 190
Bibliography / 文献 191
Chapter 14: Successive Refinement / 逐步改进 193
Args Implementation / Args 的实现 194
Args: The Rough Draft / Args:草稿 201
String Arguments / 字符串类型参数 214
Conclusion / 小结 250
Chapter 15: JUnit Internals / JUnit 内幕 251
The JUnit Framework / JUnit 框架 252
Conclusion / 小结 265
Chapter 16: Refactoring SerialDate / 重构SerialDate 267
First, Make It Work / 首先,让它能工作 268
Then Make It Right / 让它做对 270
Conclusion / 小结 284
Bibliography / 文献 284
Chapter 17: Smells and Heuristics / 味道与启发 285
Comments / 注释 286
Environment / 环境 287
Functions / 函数 288
General / 一般性问题 288
Java 307
Names / 名称 309
Tests / 测试 313
Conclusion / 小结 314
Bibliography / 文献 315
Appendix A: Concurrency II / 并发编程II 317
Appendix B: org.jfree.date.SerialDate 349
Appendix C: Cross References of Heuristics / 启发式交叉参考 409
Epilogue / 结束语 411

本目录推荐