Lendable: Why Inheritance?
This project is intended to get you to practice some of the programming and design techniques discussed in class recently. The complete code to simulate a library lending system is given in Java. It consists of the following activities:
- understand the current code
- refactor the current code
Understanding the Design
First, look at this complete Java solution to the problem. Start by reading it and making sure you understand the given code. There are many different kinds of items that can be checked out of the library. Analyze the design of the current program from the perspective of how open it is to adding additional kinds of items and how closed it is to modification.
To help direct your analysis, consider the following questions:
- What code has to change to add a new
Lendableitem? - What code has to be written to add a new
Lendableitem? - What is different about the
Lendablesubclasses? - How is the code currently tested?
- How much of the code is covered by this testing?
Refactoring
You should examine the code given and refactor it to remove the inheritance hierarchy of Lendables such that
your refactored code still solves the problem in a general manner.