University of Leicester Department of Computer Science

CO7206 - Fall 2003 Assignment #3 (8%)

Due on Nov. 28, 2003 at 11:59 pm


Given the attached program

1-     Review the program and produce a list of all the bad smells in this code

2-     Refactor this program by countering each bad smell with one or more refactorings

3-     Produce a report that describes the steps of the refactorings you implemented. For each step describe:

        Which bad smell or other reason was behind this refactoring

        Where in the code, this smell exists (e.g., method X is too long).

        The name of the refactoring, if it is in the catalogue, or a description of it if it is your own refactoring.

        A description of the refactoring implementation in the given code (e.g., the loop that does Y was extracted from X to a new method Z)

4-     Add to the report a comparison of the original and the final versions of the given program using OO Complexity and Maintainability metrics. Discuss the differences between the two versions.

5-     Store the code for refactoring step in a separate directory with serial version numbers. Add to each version a ReadMe.txt file that describes: (a) What bad smell in the previous version was removed and using which refactoring. (b) What bad smell is now going to be dealt with and using which refactoring.

6-     In a separate directory store the code used for testing the program and the test cases used.

7-     Create a zip file with all the versions of the code, each in a separate directory, and the testing suite.

8-     Submit the report and the zip file.


1-     Remember that the first step in refactoring is preparing a suitable test suite.

2-     Remember that refactoring needs to be done one small step at a time.

3-     There is no obligation to use any particular tool. However, instead of wasting time doing the work manually (e.g., implementing refactorings and counting the lines of code), I would strongly encourage you to invest the time instead in speed learning a tool that can do the job instantaneously. A list of possible tools is suggested below. But I did not have a chance to try all of them. You may be able to find other free or better tools on your own.

4-     There is no upper or lower limit on the length of your report. Certainly you do not need to write using the detailed style of Fowler, used to explain refactoring to his readers. But need to write enough description that helps me understand your steps to change the code and the rationale behind each step.


q       For examples on refactoring, read the Refactoring Reading List

q       The JUnit testing framework can be used for automating testing. It has a Cookbook.

q       IntelliJ and JRefactory are tools that automate refactoring implementation

q       Finally, here is a brief on complexity and maintainability metrics suitable for OO code.

q       And a possible tool, JMetrics, for collecting metrics about Java code.