Appendix A. Answers to Selected Questions
Exercise 1. Small Steps
Most refactorings reflect this attitude (safety even in mid-refactoring). Consider our Encapsulate Field example. Even this simple program compiled three times. Or look at Extract Method: rather than simply cutting the old code and moving it, Fowler's catalog suggests copying the code and adjusting it before deleting the old version.
Exercise 2. Simple Design
Passes all tests. “If it doesn't have to work, I can give it to you right now.”
Communicates. This makes an appeal to our intuition about future readers of our code (including ourselves).
No duplication. Duplicate code is asking for trouble; it's too vulnerable to changes in one place but not in ...
Get Refactoring Workbook now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.