Clean Code

A Handbook of Agile Software Craftsmanship
Langbeschreibung
Anyone with a modicum of industry experience knows that there is an awful lot
Inhaltsverzeichnis
Foreword xixIntroduction xxvOn the Cover xxixChapter 1: Clean Code 1There Will Be Code 2Bad Code 3The Total Cost of Owning a Mess 4Schools of Thought 12We Are Authors 13The Boy Scout Rule 14Prequel and Principles 15Conclusion 15Bibliography 15Chapter 2: Meaningful Names 17Introduction 17Use Intention-Revealing Names 18Avoid Disinformation 19Make Meaningful Distinctions 20Use Pronounceable Names 21Use Searchable Names 22Avoid Encodings 23Avoid Mental Mapping 25Class Names 25Method Names 25Don’t Be Cute 26Pick One Word per Concept 26Don’t Pun 26Use Solution Domain Names 27Use Problem Domain Names 27Add Meaningful Context 27Don’t Add Gratuitous Context 29Final Words 30Chapter 3: Functions 31Small! 34Do One Thing 35One Level of Abstraction per Function 36Switch Statements 37Use Descriptive Names 39Function Arguments 40Have No Side Effects 44Command Query Separation 45Prefer Exceptions to Returning Error Codes 46Don’t Repeat Yourself 48Structured Programming 48How Do You Write Functions Like This? 49Conclusion 49SetupTeardownIncluder 50Bibliography 52Chapter 4: Comments 53Comments Do Not Make Up for Bad Code 55Explain Yourself in Code 55Good Comments 55Bad Comments 59Bibliography 74Chapter 5: Formatting 75The Purpose of Formatting 76Vertical Formatting 76Horizontal Formatting 85Team Rules 90Uncle Bob’s Formatting Rules 90Chapter 6: Objects and Data Structures 93Data Abstraction 93Data/Object Anti-Symmetry 95The Law of Demeter 97Data Transfer Objects 100Conclusion 101Bibliography 101Chapter 7: Error Handling 103Use Exceptions Rather Than Return Codes 104Write Your Try-Catch-Finally Statement First 105Use Unchecked Exceptions 106Provide Context with Exceptions 107Define Exception Classes in Terms of a Caller’s Needs 107Define the Normal Flow 109Don’t Return Null 110Don’t Pass Null 111Conclusion 112Bibliography 112Chapter 8: Boundaries 113Using Third-Party Code 114Exploring and Learning Boundaries 116Learning log4j 116Learning Tests Are Better Than Free 118Using Code That Does Not Yet Exist 118Clean Boundaries 120Bibliography 120Chapter 9: Unit Tests 121The Three Laws of TDD 122Keeping Tests Clean 123Clean Tests 124One Assert per Test 130F.I.R.S.T. 132Conclusion 133Bibliography 133Chapter 10: Classes 135Class Organization 136Classes Should Be Small! 136Organizing for Change 147Bibliography 151Chapter 11: Systems 153How Would You Build a City? 154Separate Constructing a System from Using It 154Scaling Up 157Java Proxies 161Pure Java AOP Frameworks 163AspectJ Aspects 166Test Drive the System Architecture 166Optimize Decision Making 167Use Standards Wisely, When They Add Demonstrable Value 168Systems Need Domain-Specific Languages 168Conclusion 169Bibliography 169Chapter 12: Emergence 171Getting Clean via Emergent Design 171Simple Design Rule 1: Runs All the Tests 172Simple Design Rules 2–4: Refactoring 172No Duplication 173Expressive 175Minimal Classes and Methods 176Conclusion 176Bibliography 176Chapter 13: Concurrency 177Why Concurrency? 178Challenges 180Concurrency Defense Principles 180Know Your Library 182Know Your Execution Models 183Beware Dependencies Between Synchronized Methods 185Keep Synchronized Sections Small 185Writing Correct Shut-Down Code Is Hard 186Testing Threaded Code 186Conclusion 190Bibliography 191Chapter 14: Successive Refinement 193Args Implementation 194Args: The Rough Draft 201String Arguments 214Conclusion 250Chapter 15: JUnit Internals 251The JUnit Framework 252Conclusion 265Chapter 16: Refactoring SerialDate 267First, Make It Work 268Then Make It Right 270Conclusion 284Bibliography 284Chapter 17: Smells and Heuristics 285Comments 286Environment 287Functions 288General 288Java 307Names 309Tests 313Conclusion 314Bibliography 315Appendix A: Concurrency II 317Client/Server Example 317Possible Paths of Execution 321Knowing Your Library 326Dependencies Between Methods Can Break Concurrent Code 329Increasing Throughput 333Deadlock 335Testing Multithreaded Code 339Tool Support for Testing Thread-Based Code 342Conclusion 342Tutorial: Full Code Examples 343Appendix B: org.jfree.date.SerialDate 349Appendix C: Cross References of Heuristics 409Epilogue 411Index 413
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.
ISBN-13:
9780132350884
Veröffentl:
2008
Erscheinungsdatum:
01.03.2009
Seiten:
464
Autor:
Robert C. Martin
Gewicht:
806 g
Format:
233x179x21 mm
Sprache:
Englisch

48,14 €*

Lieferzeit: Sofort lieferbari
Alle Preise inkl. MwSt. | zzgl. Versand