Extract Method
From CSSEMediaWiki
(Difference between revisions)
Brett Ward (Talk | contribs) m (Page was just an example, added generic explanation) |
|||
Line 1: | Line 1: | ||
+ | Turn the fragment into a method whose name explains the purpose of the method. | ||
printOwing() { | printOwing() { | ||
Line 19: | Line 20: | ||
System.out.println ("amount " + outstanding); | System.out.println ("amount " + outstanding); | ||
} | } | ||
+ | |||
+ | == See Also == | ||
+ | |||
+ | {{Refactoring}} |
Revision as of 00:22, 27 July 2009
Turn the fragment into a method whose name explains the purpose of the method.
printOwing() { printBanner(); //print details System.out.println ("name: " + _name); System.out.println ("amount " + getOutstanding()); }
becomes
void printOwing() { printBanner(); printDetails(getOutstanding()); }
void printDetails (double outstanding) { System.out.println ("name: " + _name); System.out.println ("amount " + outstanding); }
See Also