Up Previous Next Title Page Contents

4.4.4 Framework code

The original code was much in need of refactoring, having been the authors’ first Java application, and not really intended to be looked at. First we refactored out the mass of user-interface, control and state machine behavior from the applet into the classes of their own. From this, it was easier to see what had to be done.

The majority of classes were platform independent, requiring only basic Java functionality. The user interface and control APIs are different for MIDP, so a separate WatchCanvas class had to be made for MIDP. Being a second attempt at the same functionality, with more Java experience than before, it was soon noticed that the same solutions could be applied to the WatchCanvas class for applets too. This resulted in smoother updating in the applet, as well as keeping the applet and MIDP versions more visually similar. As a result, some behavior is still duplicated between the two platforms’ versions of that class, but not enough to merit refactoring it out into its own class.

MIDP does not have the Applet class, so our Applet was replaced with a Midlet, the MIDP equivalent. There appears to be no reason why an Applet should not have been used for MIDP: the same functions are present, just with different names. As our generated applet classes subclass from AbstractWatchApplet, our framework subclass of Applet, they work as subclasses of AbstractWatchApplet just fine, even when it is a subclass of Midlet. Thus, no changes were necessary to the generator that generates the applet/midlet for each WatchApplication.

Up Previous Next Title Page Contents