Simberon Design Minute
 

Helper Classes

Recently, I needed to write a conversion from latitude and longitude coordinates to Universal Transverse Mercator or UTM coordinates. At first, I coded the conversion into the Lat/Long coordinate class. Then I found that it really wasn't a good place for it. First, there were a large number of private methods that were involved in the conversion. On top of that, many of the methods calculated a value but were called many times during the conversion. We should really calculate the value once and cache it for later. Finally, I also needed to convert from UTM back to Lat/Long and many of the conversion methods were the same. The solution was obvious - use a converter class which could be created and used temorarily during the conversion. This class contained all the private methods needed for the conversion and instance variables to cache the answers. This is called a Helper class and it helps simplify the design.

Download