Adept Software Development

Adept: (A)pplication (D)evelopment (E)nterprise to (P)ersonal (T)ransition. It is a system I am developing to leverage Enterprise developer skills to produce stand-alone software for other market segments. This is a general software development blog discussing issues about project, architecture, design and development. The emphasis will be in Java, but many of the issues will be more general. Almost all will be technical.

http://marringtons.com

Monday, September 14, 2009

Refactor Heaven

One of the reasons I considered creating Trogger (The Travel Log) is that it has a lot of common functionality with Golf Adept - for both the mobile application and the server side.
Modern development thinking is that we should not write code that is not needed. With modern refactoring IDEs this is now not only possible but a pleasure. Look at the history of the Golf Adept mobile code.
Originally there was
GolfAdept
Then when I needed to create a version for Android I refactored the code into
GolfAdeptMidlet (and GolfAdeptAndroid) and;
GolfAdeptCommon
Given that 90% of the mobile code for Trogger is common with Golf Adept, more refactoring was in order.
mobile.common and;
mobile.midlet.common and;
mobile.golfadept.common and;
mobile.golfadept.midlet
with a similar set for Trogger.
Modern thinking is that we should not develop, keep or maintain code that is not currently in use. It is true that almost every developer has written code for an eventuality that never happened. It is equally true that if you don't consider future requirements then your code will not be reusable.
With J2ME being an old and out-of-favour platform I needed to consider other platforms from the first line of code. This amounted to a single decision. Create a clear separation between business logic and I/O code. This worked well for the Android port. I can also automatically generate business logic code for the iPhone and Windows Mobile in C++ while only having to rewrite the much smaller platform specific section.
mobile.common has 4,869 code lines and;
mobile.midlet.common has 770 code lines and;
mobile.golfadept.common has 2,541 code lines and;
mobile.golfadept.midlet has 10 code lines
The application specific midlet code is not just a boot-strap. Platform dependent code is not clearly separated and takes up about 10% of the code base.
Because of the core common code I managed to write the base Trogger application in less than 2 days. It might take me a full 5 days to add all the frills I want.
Similar refactoring was needed for the server side (Python on the Google Appengine). I will save that for another discussion.

0 Comments:

Post a Comment

<< Home