Java refactoring exercise taken from http://patrickwilsonwelsh.com/?p=18 on making a small piece of code more maintainable and extensible