Encapsulate Downcast

A method returns an object that needs to be downcasted by its callers.

Move the downcast to within the method.


Object lastReading() {

	return readings.lastElement();

}


Reading lastReading() {

	return (Reading) readings.lastElement();

}

For more information see page 308 of Refactoring

| Refactoring Home | | Alphabetical List |