Appendix A. Answers to Selected Questions
We’ve included answers to some of the problems here. Where we’ve omitted answers, it’s usually because we’ve asked you to work in your own code or because we want you to consider an issue on your own.
The Refactoring Cycle
Exercise 2.1: 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 the other.
- Fewest classes and methods. All things being equal, we prefer smaller code.
The bottom line is that there’s an appeal to the reader’s ability ...