Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 3. Measured Smells > Conclusion - Pg. 20

Measured Smells 20 See Appendix A for solutions. More Challenges EXERCISE 7 Smells and Re- Consider these smells: factorings. A. Comments B. Large Class C. Long Method D. Long Parameter List For each refactoring in the following list, write the letter for the smell(s) it might help cure: ___ Duplicate Observed Data ___ Extract Class ___ Extract Interface ___ Extract Method ___ Extract Subclass ___ Introduce Assertion ___ Introduce Parameter Object ___ Preserve Whole Object ___ Rename Method ___ Replace Parameter with Method See Appendix A for solutions. EXERCISE 8 See Appendix A for solutions. Triggers. Consider the smells described in this chapter (Comments, Large Class, Long Method, Long Parameter List). A. B. Which of these do you find most often? Which do you create most often? To stop children from sucking their thumbs, some parents put a bad-tasting or spicy solution on the child's thumb. This serves as a trigger that reminds the child not to do that. What triggers can you give yourself to help you recognize when you're just beginning to create one of these smells? See Appendix A for solutions. Conclusion The smells in this chapter are the easiest to identify. They're not necessarily the easiest to fix. There are other metrics that have been applied to software. Many of them are simply refinements of code length. Pay attention when things feel like they're getting too big. There is not a one-to-one relationship between refactorings and smells; we'll run into the same refactorings again. For example, Extract Method is a tool that can fix many problems.