Last active
August 29, 2015 14:08
-
-
Save up1/7b6e165e6373ea6487f1 to your computer and use it in GitHub Desktop.
Demo :: Extract Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
public void resetSession() { | |
Foo.start(); | |
Foo.open(); | |
Foo.maximizeWindow(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
public void resetSession() { | |
Foo.start(); | |
openAndMaximize(); | |
} | |
private void openAndMaximize() { | |
Foo.open(); | |
Foo.maximizeWindow(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void printData() { | |
printBanner(); | |
//Print Details | |
System.out.println("Detail 1"); | |
System.out.println("Detail 2"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void printData() { | |
printBanner(); | |
printDetails(); | |
} | |
private void printDetails() { | |
System.out.println("Detail 1"); | |
System.out.println("Detail 2"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void printData() { | |
List<Order> orders = getOrders(); | |
double result = 0.0; | |
printBanner(); | |
//calculate result | |
for(Order order : orders) { | |
result += order.getAmount(); | |
} | |
printDetails(result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void printData() { | |
printBanner(); | |
double result = getResult(); | |
printDetails(result); | |
} | |
private double getResult() { | |
List<Order> orders = getOrders(); | |
double result = 0.0; | |
for(Order order : orders) { | |
result += order.getAmount(); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment