Skip to main content

Posts

Showing posts with the label Return type

Java Generics Return type refactoring exercise

One of my more interesting tasks of the past few weeks was to refactor an existing method to use Generics in a method's return type and simplify the readability of code that calls the method. The starting point was this method: public static Object getHandler(Class<?> aClass) throws HandlerException  {    if (handlerFactory == null)       handlerFactory = new HandlerFactory();    return handlerFactory.getHandler(aClass); }