Homework 2: Design

Due date: Tuesday, February 1, at the beginning of class

1. Abstract Classes and Interfaces (25 points)
Take a look at the Java collections library (a part of the Java standard library; it consists of all the classes that implement the interface java.util.Collection).
a) Identify 3 interfaces that are used by this library. Explain the purpose of each, and why its purpose cannot be fullfilled by a class.
b) Identify 3 abstract classes that are used by this library. Explain the purpose of each, and why its purpose cannot be fulfilled by a concrete class.

2. Polymorphism (25 points)
Look at your favorite class library (for example, the C++ standard library or the Java standard library) and find 5 different operations that are polymorphic. For each operation, give its specification, give the class or interface in which it is declared, and two classes in which the operation is implemented. Describe each of the two implementations and how they differ from each other.

3. Libraries (50 points)
Choose a library that you are using for your project (other than the Java collections library).
a) Explain its overall purpose. Discuss its main features.
b) Pick 10 related, non-trivial classes from the library. Explain the purpose of each.
c) Draw a UML class diagram that shows how the 10 classes from b are related to each other. Include all relations between the 10 classes.
d) How could the design of this library be improved? Find 3 problems with the design of this library. Explain each problem, and suggest how it could be resolved.
e) Explain which parts of the library will be used for your project, and name the most important classes you will be using.


CS 498 Spring 2005