Extract Method
将这段代码放进一个独立函数中,并让函数名称解释该函数的用途。
void printOwing(double amount) {
printBanner();
//print details
System.out.println("name:" + _name);
System.out.println("amount" + amount);
}
| |
| |
\ /
void printOwing(double amount) {
printBanner();
printDetails(amount);
}
void printDetails(double amount) {
System.out.println("name:" + _name);
System.out.println("amount" + amount);
}