The Code Clean Way

Links:Pan.baidu.com/s/1b6e2CgZ0…Extraction code: 5D2V

“There are two reasons to read this book: first, you’re a programmer; Second, you want to be a better programmer. Good, IT needs better programmers!” — Robert C. Martin

While bad code can work, if it’s untidy, it can sink the entire development team, and poorly written code consumes countless hours and resources every year. But it is not inevitable.

Robert C. Martin, the renowned software expert, offers a revolutionary vision. Along with his colleagues at Object Mentor, he has distilled the values of software craftsmanship from their good agile practices of clean code to make you a better programmer — once you start reading this book. What do you need to do to read this book? You’ll read code — lots of code. This book will make you think about what is right code and what is wrong code. More importantly, this book will force you to reassess your professional values and commitment to your craft. · The difference between good and bad code; · How to write good code and how to turn bad code into good code; · How to create good names, good functions, good objects and good classes; · How to format code to maximize its readability; · How to fully implement error handling without interfering with code logic; · How to conduct unit testing and test-driven development.

Table of Contents Chapter 1 Clean Code 1 1.1 Have Code 2 1.2 Bad Code 2 1.3 The Cost of Chaos 3 1.3.1 Gorgeous new Design 4 1.3.2 Attitude 4 1.3.3 Puzzles 5 1.3.4 The Art of Clean Code 5 1.3.5 What is Clean Code 6 1.4 Schools of Thought 10 1.5 We are the Author 11 1.6 Scouting Rules 12 1.7 Prequels and Principles 12 1.8 Summary 13 1.9 Literature 13 Chapter 2 Meaningful Naming 14 2.1 Introduction 14 2.2 Worthy of the name 15 2.3 Avoid Misleading 16 2.4 Make meaningful distinctions 17 2.5 Use readable names 18 2.6 Use searchable names 19 2.7 Avoid encodings 20 2.7.1 Hungarian notation 20 2.7.2 Member prefixes 21 2.7.3 Interfaces and implementations 21 2.8 Avoid mental mapping 21 2.9 Class names 22 2.10 Method names 22 2.11 Stop Being Clever 22 2.12 One word for each concept 23 2.13 No puns 23 2.14 Use solution domain names 24 2.15 Use names derived from the problem domain 24 2.16 Add meaningful context 24 2.17 Don't add useless context 26 2.18 Last Words 27 Chapter 3 Functions 28 3.1 Short 31 3.2 Do one thing only 32 3.3 One level of abstraction per function 33 3.4 Switch Statements 34 3.5 Use descriptive names 35 3.6 Function parameters 36 3.6.1 General form of single-parameter functions 37 3.6.2 Identifying parameters 37 3.6.3 Two-parameter functions 38 3.6.4 Three-parameter functions 38 3.6.5 Parameter objects 39 3.6.6 Parameter list 39 3.6.7 Verbs and Keywords 39 3.7 No Side effects 40 3.8 Separating instructions from queries 41 3.9 Using exception substitution to return error codes 42 3.9.1 Extracting a try/catch block 42 3.9.2 Error handling is one thing 43 3.9.3 43 3.10 Do not repeat yourself 44 3.11 Structured programming 44 3.12 How to write such functions 45 3.13 结构 45 3.14 SetupTeardownIncluder procedures 45 3.15 document48 Chapter 4 Notes 49 4.1 Notes do not Beautify Bad code 50 4.2 Use code to illustrate 51 4.3 Good notes 51 4.3.1 Legal Information 51 4.3.2 Informative notes 51 4.3.3 Interpretation of intent 52 4.3.4 Interpretation 53 4.3.5 Warning 53 4.3.6 TODO comments 54 4.3.7 Magnification 55 4.3.8 Javadoc55 in public apis 4.4 Bad comments 55 4.4.1 Muttering 55 4.4.2 Redundant comments 56 4.4.3 Misleading comments 58 4.4.4 4.4.6 Nonsense 60 4.4.7 Horrible nonsense 62 4.4.8 Do not use a function or variable when it is available 62 4.4.9 positional markers 62 4.4.10 after parentheses 63 4.4.11 Attribution and attribution 63 4.4.12 Commented out code 64 4.4.13 HTML comments 64 4.4.14 Non-local information 65 4.4.15 Too much information 65 4.4.16 Obscure connections 66 4.4.17 function headers 66 4.4.18 Javadoc66 in Non-public Code 4.4.19 Example 66 4.5 Literature 70 Chapter 5 Format 71 5.1 Purpose of format 72 5.2 Vertical format 72 5.2.1 Learning from newspapers 73 5.2.2 Vertical partitions between concepts 73 5.2.3 Vertical proximity 74 5.2.4 vertical distance 75 5.2.5 Vertical sequence 79 5.3 Horizontal format 80 5.3.1 Horizontal separation and proximity 81 5.3.2 horizontal alignment 82 5.3.3 indentation 83 5.3.4 Empty range 84 5.4 Team rules 85 5.5 "Uncle Bob" format rules 85 Chapter 6 Objects and data structures 88 6.1 Data abstraction 88 6.2 Data, antisymmetry of objects 90 6.3 Demeter's law 92 6.3.1 train wreck 92 6.3.2 Hybridity 93 6.3.3 Hidden structures 93 6.4 Data transfer objects 94 6.5 Summary 95 6.6 Literature 96 Chapter 7 Error Handling 97 7.1 Using exceptions instead of return codes 98 7.2 Writing try-catch-finally statements first 99 7.3 Using unchecked exceptions 100 7.4 Give the description of the environment in which the exception occurs 101 7.5 Define the exception class according to the needs of the caller 101 7.6 Define the general flow 103 7.7 Do not Return a NULL value 104 7.8 Do not pass a NULL value 105 7.9 Summary 106 7.10 Reference 106 Chapter 8 Boundary 107 8.1 Using third-party code 108 8.2 Browsing and learning boundaries 109 8.3 Learning log4J110 8.4 Benefits of learning tests beyond free 112 8.5 Using code that does not yet exist 112 8.6 Clean boundaries 113 8.7 Literature 114 Chapter 9 Unit Tests 115 9.1 The Three Laws of TDD 116 9.2 Keeping Tests clean 117 9.3 Clean Tests 118 9.3.1 Domain-specific testing languages 120 9.3.2 Double standards 121 9.4 One assertion per test 123 9.5 F.I.R.S.T. 125 9.6 Summary 125 9.7 Literature 126 Chapter 10 Category 127 organization of 10.1 category 128 10.2 category should be short 128 10.2.1 Principle of single rights and responsibilities 130 10.2.2 Cohesion 131 10.2.3 Maintaining cohesion results in many short classes 132 10.3 Organizing for modification 138 10.4 Reference 141 Chapter 11 Systems 142 11.1 How to Build a City 143 11.2 Separating the construction and use of systems 143 11.2.1 Disintegrating main144 11.2.2 Factory 145 11.2.3 Dependency Injection 145 11.3 Capacity expansion 146 11.4 Java Proxy 149 11.5 Pure Java AOP Framework 151 11.6 AspectJ aspects 154 11.7 Test-driven System Architecture 154 11.8 Optimization decision 155 11.9 Judicious use of criteria that add demonstrable value 155 11.10 System needs DOMAIN-specific language 156 11.11 Summary 156 11.12 Literature 156 Chapter 12 Overlap 158 12.1 Neatness through overlapping design 158 12.2 Simple Design Rules 1: Run All Tests 159 12.3 Simple Design Rules 2 to 4: Refactoring 159 12.4 Non-repeatable 160 12.5 Expressability 162 12.6 As few classes and methods as possible 163 12.7 Summary 163 12.8 Literature 163 Chapter 13 Concurrent Programming 164 13.1 Why Concurrency 165 13.2 Challenge 166 13.3 Concurrency Defense principle 167 13.3.1 Single Accountability Principle 167 13.3.2 Corollary: Limiting data scope 167 13.3.3 Corollary: Using data copies 168 13.3.4 Corollary: Threads should be as independent as possible 168 13.4 Understand the Java library 168 13.5 Understand the execution model 169 13.5.1 Producer-consumer model 170 13.5.2 Reader-author model 170 13.5.3 Banquet Philosopher 170 13.6 Be wary of dependencies between synchronized methods 170 13.7 Keeping the synchronization area small 171 13.8 It is difficult to write proper shutdown code 171 13.9 Testing threaded code 172 13.9.1 Treating pseudo-failures as a possible threading problem 172 13.9.2 Making non-threaded code work first 172 13.9.3 Writing Pluggable thread code 173 13.9.4 Writing adjustable thread code 173 13.9.5 Running more threads than the number of processors 173 13.9.6 Running on different platforms 173 13.9.7 Device trial-and-error code 174 13.9.8 Hard coding 174 13.9.9 Automation 175 13.10 Summary 176 13.11 Literature 176 Chapter 14 Progressive Improvement 177 14.1 Implementation of Args 178 14.2 Args: Draft 185 14.2.1 so I paused 196 14.2.2 progressive 197 14.3 String type Parameters 199 14.4 Summary 236 Chapter 15 JUnit Insider 237 15.1 JUnit Framework 238 15.2 Summary 251 Chapter 16 Refactoring SerialDate252 Make it work 253 16.2 Make it right 255 16.3 Summary 268 16.4 Literature 268 Chapter 17 Taste and Inspiration 269 17.1 Notes 270 17.2 Environment 271 17.3 Functions 271 17.4 General questions 272 17.5 Java288 17.6 Name 291 17.7 Tests 295 17.8 Summary 296 17.9 Literature 296 Appendix A Concurrent Programming II297 Appendix Borg.free.date.serialdate326 Concluding sentence 388Copy the code

Finally, there are hundreds of Internet e-books for you, come and get them if you need them. Click on the get

This page books are from the network, if there is infringement, please contact me immediately delete. My email address:[email protected]