Com S 362 --- Object-Oriented Analysis and Design EXERCISE 17: MORE GRASP DESIGN PATTERNS (File $Date: 2003/11/29 23:38:07 $) The purpose of this exercise is for you to learn more about the GRASP design patterns of indirection and protected variations. As with all exercises, this is to be done individually, not in teams. And it is due the day this topic is planned to be discussed in class, unless specified otherwise (see the syllabus at: http://www.cs.iastate.edu/~cs362/syllabus.shtml). As with all exercises, you have two choices for doing the work. You can either: - complete it as specified or - write down questions or problems that you had in trying to complete it. If you write down questions or problems you have, these should be detailed enough so that we can tell that you have read the materials and thought about them. (Don't just write: "I couldn't get it to work; say what you tried and what you didn't understand.) During the class where this exercise is discussed, you should try to get help with these by explaining what you did and what your problems or confusions are. Don't be shy; there will be other people with the same problem, and everyone can learn by discussing these issues. 1. [Indirection] Read Sections 22.3 and then 23.1 of Larman's book "Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process" (Second Edition, Prentice Hall PTR, Upper Saddle River, NJ, 2001). a. What problem does the indirection design pattern solve? b. In what sense is the adapter pattern an instance of the indirection pattern? c. Consider the standard Java library class java.io.FilterInputStream. According to the documentation, this class " contains some other input stream, which it uses as its basic source of data, possibly transforming the data along the way or providing additional functionality." Do you think the design of FilterInputStream uses the indirection pattern? d. Does the design of FilterInputStream use the Adapter pattern? 2. [Protected Variations] Read Section 22.4 of Larman's book "Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and the Unified Process" (Second Edition, Prentice Hall PTR, Upper Saddle River, NJ, 2001). a. What is a variation point? b. What is an evolution point? c. From the first iteration of your team project, what are the most likely places that seem to be possible points of variation or evolution in your design? d. Is it worth using the protected variations pattern to plan ahead for these places in your design? If so, what mechanisms could you use to protect the design from them? WHAT TO HAND IN You should have at the beginning of class, written answers to the above questions (or written out questions and problems you encountered for each part). Make sure your name is on these. Attach the printouts, if any, requested above. ADDITIONAL READINGS If you have time, read the section on the Adapter pattern (pp. 139ff) in Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides's book "Design Patterns: Elements of Reusable Object-Oriented Software" (Addison-Wesley, Boston, MA, 1995).