Introduce Foreign Method

A server class you are using needs an additional method, but you can't modify the class.

Create a method in the client class with an instance of the server class as its first argument.

Date newStart = new Date (previousEnd.getYear(),
						previousEnd.getMonth(), previousEnd.getDate() + 1);

Date newStart = nextDay(previousEnd);

private static Date nextDay(Date arg) {
	return new Date (arg.getYear(),arg.getMonth(), arg.getDate() + 1);
}

For more information see page 162 of Refactoring

| Refactoring Home | | Alphabetical List |