书籍 Clean Code的封面

Clean Code

Robert C. Martin

出版社

Prentice Hall

出版时间

2008-08-10

ISBN

9780132350884

评分

★★★★★
书籍介绍

Even bad code can function. But if code isn’t clean, it can bring a development organization to its knees. Every year, countless hours and significant resources are lost because of poorly written code. But it doesn’t have to be that way.

Noted software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship. Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code “on the fly” into a book that will instill within you the values of a software craftsman and make you a better programmer—but only if you work at it.

What kind of work will you be doing? You’ll be reading code—lots of code. And you will be challenged to think about what’s right about that code, and what’s wrong with it. More importantly, you will be challenged to reassess your professional values and your commitment to your craft.

Clean Code is divided into three parts. The first describes the principles, patterns, and practices of writing clean code. The second part consists of several case studies of increasing complexity. Each case study is an exercise in cleaning up code—of transforming a code base that has some problems into one that is sound and efficient. The third part is the payoff: a single chapter containing a list of heuristics and “smells” gathered while creating the case studies. The result is a knowledge base that describes the way we think when we write, read, and clean code.

Readers will come away from this book understanding

How to tell the difference between good and bad code

How to write good code and how to transform bad code into good code

How to create good names, good functions, good objects, and good classes

How to format code for maximum readability

How to implement complete error handling without obscuring code logic

How to unit test and practice test-driven development

This book is a must for any developer, software engineer, project manager, team lead, or systems analyst with an interest in producing better code.

Robert C. “Uncle Bob” Martin has been a software professional since 1970 and an international software consultant since 1990. He is founder and president of Object Mentor, Inc., a team of experienced consultants who mentor their clients worldwide in the fields of C++, Java, C#, Ruby, OO, Design Patterns, UML, Agile Methodologies, and eXtreme programming.

用户评论
verbose
一个有故事的老男人
和同组同事在周会上读了一年多的书。觉得书中原则可简化成「为之后阅读/修改代码的自己或他人减轻认知负荷」。
醍醐灌顶,每一个程序猿都应该尽早读的一本书,早一天读也就少一天浪费他人和自己的生命了~
Aweshhome!
这如同与前辈关于代码可阅读性的一场谈话。不敢保证我同意书里的每一句话,但本书提供了一个senior&experienced的视角看待代码,这让我受益良多
老外程序员真的敬业,不放过任何细节。读了一遍,感觉还是需要大量实践才能真正理解里面的精髓
自从读完clean code,看见旧代码就想重构(不是
刚开始写代码的时候读很有用
后面几章java味太冲了直接过了. 前面几章讲的太好了, 给了非常有用的原则. 比如函数应该只做一件事, 参数不要太多, 尽量不用swtich(如果一定要用, 最好只出现一次, 比如factory pattern create object的时候); talk to friends, not to strangers (不要x.foo().bar()这样); 用exception代替error code, 不要返回null, 也不要传null, 考虑使用一个特殊值代替(比如python可以考虑返回空数组[], cxx17可以用std::optional); 用第三方代码, 不要直接call raw api, 最好写一个adapter, 这样对方更新了代码对自己影响小;一定要写unittest