Clean Code. Whew!

Posted by Uncle Bob on 04/08/2008

I’ve been working on this book for several years now. After a flurry of effort (you might have noticed I’ve been quiet lately) I’m very pleased to say that I’m done with the writing and am preparing the manuscript for production. See The Prentice Hall Listing

Table of Contents

Clean Code    1

   There Will Be Code    1

   Bad Code    2

   The Total Cost of Owning a Mess.    3

   Schools of Thought.    11

   We are Authors.    12

   The Boy Scout Rule    13

   Prequel and Principles    14

   Conclusion    14

   Bibliography    15

Meaningful Names by Tim Ottinger    17

   Introduction    17

   Use Intention-revealing Names    17

   Avoid Disinformation    19

   Make Meaningful Distinctions    20

   Use Pronounceable Names    21

   Use Searchable Names    22

   Avoid Encodings    23

   Avoid Mental Mapping    24

   Class Names    25

   Method Names    25

   Don't Be Cute    25

   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

Functions    31

   Small!    34

   Do one thing.    35

   One level of abstraction per function.    36

   Switch Statements.    37

   Use descriptive names.    39

   Function Arguments.    39

   Have no side-effects.    43

   Command Query Separation    44

   Prefer exceptions to returning error codes.    45

   Don't Repeat Yourself.    47

   Structured Programming    48

   How do you write functions like this?    48

   Conclusion    49

   SetupTeardownIncluder    49

   Bibliography    52

Comments    53

   Comments do not make up for bad code.    55

   Explain yourself in code.    55

   Good Comments    55

   Bad Comments    59

   Example    71

   Bibliography    74

Formatting    75

   The Purpose of Formatting    76

   Vertical Formatting    76

   Horizontal Formatting    84

   Team Rules    89

   Uncle Bob's Formatting Rules.    90

Objects and Data Structures    93

   Data Abstraction    93

   Data/Object anti-symmetry.    95

   The Law of Demeter    97

   Data Transfer Objects    99

   Conclusion    101

   Bibliography    101

Error Handling by Michael Feathers    103

   Use Exceptions Rather than Return Codes    103

   Write Your Try-Catch-Finally Statement First    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    110

   Don't Pass Null    111

   Conclusion    112

   Bibliography    112

Boundaries by James Grenning    113

   Bibliography    119

Unit Tests    121

   The Three Laws of TDD    122

   Keeping Tests Clean    123

   Clean Tests    124

   One Assert per Test    129

   F.I.R.S.T.    132

   Conclusion    132

   Bibliography    133

Classes    135

   Class Organization    135

   Classes should be Small!    136

   Organizing for Change    146

   Bibliography    150

Systems    By Dean Wampler 151

   How would you build a city?    151

   Separate constructing a system from using it    152

   Scaling Up    155

   Java Proxies    158

   Pure Java AOP Frameworks    160

   AspectJ Aspects    163

   Test-drive the system architecture    164

   Optimize decision making    165

   Use standards wisely, when they add demonstrable value    165

   Systems need Domain-Specific Languages    166

   Conclusion    166

   Bibliography    167

Emergence By Jeff Langr    169

   Getting Clean via Emergent Design    169

   Simple Design Rule 1: Runs all the tests    170

   Simple Design Rules 2-4: Refactoring    170

   No Duplication    170

   Expressive    173

   Minimal Classes and Methods    174

   Conclusion    174

   Bibliography    174

Concurrency    by Brett Schuchert 175

   Why Concurrency?    176

   Challenges    177

   Concurrency Defense Principles    178

   Know Your Library    180

   Know Your Execution Models    181

   Beware Dependencies between Syncrhonized Methods    182

   Keep Synchronized Sections Small    183

   Writing Correct Shut-Down Code is Hard    183

   Testing Threaded Code    184

   Conclusion    188

   Bibliography    189

Successive Refinement    191

   Args Implementation    192

   Args: the rough draft.    198

   String Arguments    212

    Conclusion    246

JUnit Internals    249

   Conclusion    262

Refactoring SerialDate    263

   Conclusion    280

   Bibliography    281

Smells and Heuristics    283

   Comments    283

   Environment    284

   Functions    285

   General    285

   Java    304

   Names    306

   Tests    310

   Conclusion    311

   Bibliography    312

Concurrency II    by Brett Schuchert 313

   Client/Server Example    313

   Possible Paths of Execution    317

   Knowing Your Library    322

   Dependencies between methods can break concurrent code    325

   Increasing Throughput    329

   Deadlock    331

   Testing Multi-Threaded Code    335

   Tool Support for Testing Thread-Based Code    337

   Conclusion    338

   Tutorial: Full Code Examples    339

org.jfree.date.SerialDate    345

Cross References of Heuristics    406

Comments

Leave a response