The following methods are from classes A & B that have a common superclass

07-05-04 zhouyongofcim
The following methods are from classes A & B that have a common superclass C. Modify (that is refactor) the methods using Template method and Factory Method. Show all the methods you would create and which classes they would be in.

Class A

send( Request aRequest, URL anAddress) {

log( “send in class A called”);

NetClient sender = new HttpClient().

sender address(anAddress).

Repsonse result = sender process( aRequest).

if (resultis404()) {log(“Error in sending message”)};

}

Class B

send( Request aRequest, URL anAddress) {

log( “send in class B called”);

NetClient sender = new FtpClient ().

sender address(anAddress).

Repsonse result = sender process( aRequest).

if (result isEmpty ()) {log(“Error in sending message”)};

}

猜你喜欢