Programming Assignment 2, CSC/CPE 203

This programming assignment is the complement of the Design Document 2 assignment. The general task was already explained; this assignment description provides additional details and tips for the programming aspects of the redesign.

Objectives

Task Overview

You must identify those classes with low cohesion and then split these classes into separate classes exhibiting high cohesion. Since each of these new classes will introduce a separate type, you may need to "root" them at a single type (as defined by an interface) to satisfy Java's type checking rules. You will not introduce any additional classes beyond those used to improve cohesion (e.g., you will not use inheritance in this pair of assignments). This refactoring is quite likely to increase the amount of code through the duplication of some methods; this is expected and ok at this time.

Based on the original source code, there are likely two categories of classes with low cohesion. The first category consists of those classes that depend on ActionKind or EntityKind. The second category depends on your final distribution of the methods in the original Functions class.

As before, you are encouraged to develop both the UML design document and the code refactoring at the same time. You are further encouraged to implement the refactoring incrementally so that your refactored program executes properly at each step. You will submit the design document before the final refactoring submission to allow for feedback on your design that can then be incorporated into your refactoring.

Source Code Refactoring

Your refactoring should mirror the work done for your design document (UML diagram) augmented with feedback from your instructor.

Your refactoring must not add or remove any program functionality. The resulting program must work as before.

Tips on Refactoring Methods

You can use the compiler (on the command-line or in the IDE) to help you with your refactoring. In particular, as you introduce interfaces, the compiler will report attempts to use methods not supported by the specified type. The existence of such errors may indicate missing methods for an interface or, more likely, attempts to treat a group of objects more generally than should be supported (i.e., not all of them implement the desired operation).

As part of your refactoring, you will be eliminating the *Kind classes. This is desired to allow each new class to directly implement a single role, but has the unfortunate side-effect of eliminating a simple check of an object's "kind". This check is used, for instance, when searching for the nearest Ore to a miner.

Consider the following tips.

Assignment Submission

A github repository will be provided for you to submit your UML redesign - stay tuned for instructions.

Your submission must include all source files (even those that were unchanged). Your grader should be able to build your project based on the files submitted. (You do not need to submit the image files, the image list, or the world save file.) An explicit list of files is not given because you are creating new files for this assignment, so verify that you have submitted everything properly.