Log in Sign up
Trang chủeBookClean Code:A Handbook of Agile Software Craftsmanship
Clean Code:A Handbook of Agile Software Craftsmanship

Clean Code:A Handbook of Agile Software Craftsmanship

BRAND: PEARSON
Publisher:
PEARSON
Author:
Robert C. Martin
Edition:
(August 1, 2008) © 2009
eBook ISBN:
9780136083252
Print ISBN:
9780132350884
Type:
1 Year Subscription. Dành cho Cá nhân
eBook edition. 1 Year Subscription. Dành cho Cá nhân | Trường ĐH, Nhóm, Thư Viện: Gọi 0915920514 để báo giá Pearson, Vital Source eBook hoặc mua Sách In

Tổng quan sách

Ngay cả mã xấu cũng có thể hoạt động. Nhưng nếu mã không sạch, nó có thể khiến tổ chức phát triển phải đầu hàng. Hàng năm, vô số giờ và tài nguyên đáng kể bị mất do viết mã kém. Nhưng nó không nhất thiết phải như vậy.Chuyên gia phần mềm nổi tiếng Robert C. Martin trình bày một mô hình mang tính cách mạng với Mã sạch: Sổ tay về tay nghề thủ công phần mềm linh hoạt. Martin đã hợp tác với các đồng nghiệp của mình từ Object Mentor để chắt lọc phương pháp làm sạch mã nhanh nhẹn nhất của họ thành một cuốn sách sẽ thấm nhuần vào bạn những giá trị của một nghệ nhân phần mềm và giúp bạn trở thành một lập trình viên giỏi hơn—nhưng chỉ khi bạn làm việc chăm chỉ. vào đó.Bạn sẽ làm loại công việc gì? Bạn sẽ đọc mã—rất nhiều mã. Và bạn sẽ được thử thách suy nghĩ về điều gì đúng và điều gì sai trong mã đó. Quan trọng hơn, bạn sẽ được thử thách đánh giá lại các giá trị nghề nghiệp và sự cam kết của bạn đối với nghề của mình.Clean Code được chia thành ba phần. Phần đầu tiên mô tả các nguyên tắc, mô hình và cách thực hành viết mã sạch. Phần thứ hai bao gồm một số nghiên cứu trường hợp có độ phức tạp ngày càng tăng. Mỗi nghiên cứu điển hình là một bài tập làm sạch mã—chuyển đổi cơ sở mã có một số vấn đề thành một cơ sở mã hợp lý và hiệu quả. Phần thứ ba là phần thưởng: một chương duy nhất chứa danh sách các phương pháp phỏng đoán và “mùi” được thu thập trong khi tạo các nghiên cứu điển hình. Kết quả là một cơ sở kiến ​​thức mô tả cách chúng ta suy nghĩ khi viết, đọc và dọn dẹp mã.Người đọc sẽ không hiểu được cuốn sách nàyCách phân biệt mã tốt và mã xấuCách viết code tốt và cách chuyển code xấu thành code tốtCách tạo tên hay, chức năng tốt, đồ vật tốt, lớp tốtCách định dạng mã để dễ đọc nhấtCách triển khai xử lý lỗi hoàn chỉnh mà không che khuất logic mãCách kiểm thử đơn vị và thực hành phát triển theo hướng kiểm thử
  1. Foreword xixIntroduction xxvOn the Cover xxix
  2. Chapter 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 15
  3. Chapter 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 30
  4. Chapter 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 52
  5. Chapter 4: Comments 53Comments Do Not Make Up for Bad Code 55Explain Yourself in Code 55Good Comments 55Bad Comments 59Bibliography 74
  6. Chapter 5: Formatting 75The Purpose of Formatting 76Vertical Formatting 76Horizontal Formatting 85Team Rules 90Uncle Bob’s Formatting Rules 90
  7. Chapter 6: Objects and Data Structures 93Data Abstraction 93Data/Object Anti-Symmetry 95The Law of Demeter 97Data Transfer Objects 100Conclusion 101Bibliography 101
  8. Chapter 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 112
  9. Chapter 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 120
  10. Chapter 9: Unit Tests 121The Three Laws of TDD 122Keeping Tests Clean 123Clean Tests 124One Assert per Test 130F.I.R.S.T. 132Conclusion 133Bibliography 133
  11. Chapter 10: Classes 135Class Organization 136Classes Should Be Small! 136Organizing for Change 147Bibliography 151
  12. Chapter 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 169
  13. Chapter 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 176
  14. Chapter 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 191
  15. Chapter 14: Successive Refinement 193Args Implementation 194Args: The Rough Draft 201String Arguments 214Conclusion 250
  16. Chapter 15: JUnit Internals 251The JUnit Framework 252Conclusion 265
  17. Chapter 16: Refactoring SerialDate 267First, Make It Work 268Then Make It Right 270Conclusion 284Bibliography 284
  18. Chapter 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
Chat Zalo