Author(s): Sandi Metz
Edition: 0.3
Year: 2016
Language: English
Pages: 270
Colophon......Page 6
Dedication......Page 7
What This Book Is About......Page 8
Who Should Read This Book......Page 9
Before You Read This Book......Page 10
About the Authors......Page 11
Introduction......Page 13
1. Rediscovering Simplicity......Page 15
1.1. Simplifying Code......Page 17
1.1.1. Incomprehensibly Concise......Page 18
1.1.2. Speculatively General......Page 24
1.1.3. Concretely Abstract......Page 30
1.1.4. Shameless Green......Page 37
1.2. Judging Code......Page 40
1.2.1. Evaluating Code Based on Opinion......Page 41
1.2.2. Evaluating Code Based on Facts......Page 43
1.2.3. Comparing Solutions......Page 47
1.3. Summary......Page 51
2.1. Understanding Testing......Page 53
2.2. Writing the First Test......Page 55
2.3. Removing Duplication......Page 61
2.4. Understanding Transformations......Page 66
2.5. Tolerating Duplication......Page 67
2.6. Hewing to the Plan......Page 73
2.7. Exposing Responsibilities......Page 80
2.8. Choosing Names......Page 88
2.9. Revealing Intentions......Page 90
2.10. Writing Cost-Effective Tests......Page 92
2.11. Avoiding the Echo-Chamber......Page 95
2.12. Considering Options......Page 100
2.13. Summary......Page 103
3.1. Listening to Change......Page 105
3.2. Starting With the Open/Closed Principle......Page 109
3.3. Recognizing Code Smells......Page 112
3.4. Identifying the Best Point of Attack......Page 113
3.5. Refactoring Systematically......Page 115
3.6. Following the Flocking Rules......Page 116
3.7.1. Focusing on Difference......Page 119
3.7.2. Simplifying Hard Problems......Page 122
3.7.3. Naming Concepts......Page 124
3.7.4. Making Methodical Transformations......Page 127
3.7.5. Refactoring Gradually......Page 133
3.8. Summary......Page 140
4.1. Replacing Difference With Sameness......Page 142
4.2. Equivocating About Names......Page 146
4.3. Deriving Names From Responsibilities......Page 151
4.4. Choosing Meaningful Defaults......Page 156
4.5. Seeking Stable Landing Points......Page 165
4.6. Obeying the Liskov Substitution Principle......Page 166
4.7. Taking Bigger Steps......Page 174
4.8. Discovering Deeper Abstractions......Page 180
4.9. Depending on Abstractions......Page 189
4.10. Summary......Page 194
5.1. Selecting the Target Code Smell......Page 195
5.1.1. Identifying Patterns in Code......Page 197
5.1.2. Spotting Common Qualities......Page 200
5.1.3. Enumerating Flocked Method Commonalities......Page 207
5.1.4. Insisting Upon Messages......Page 209
5.2. Extracting Classes......Page 211
5.2.1. Modeling Abstractions......Page 212
5.2.3. Extracting BottleNumber......Page 214
5.2.4. Removing Arguments......Page 222
5.2.5. Trusting the Process......Page 229
5.3. Appreciating Immutability......Page 235
5.4. Assuming Fast Enough......Page 237
5.5. Creating BottleNumbers......Page 240
5.6. Recognizing Liskov Violations......Page 245
5.7. Summary......Page 251
6. Replacing Conditionals with Objects......Page 253
A.2. Minitest......Page 254
B.2. Doing the exercise......Page 255
B.3. Test Suite......Page 256
Acknowledgements......Page 269