Extract Method

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(Moved Extract method explanation from the duplicate code page to here)
 
(Refactoring)
Line 1: Line 1:
== Refactoring ==
+
printOwing() {
 
+
The best way to fix this bad code smell is to use [[Extract Method]] technique as shown below.
+
 
+
        printOwing() {
+
 
                 printBanner();
 
                 printBanner();
 
          
 
          

Revision as of 04:20, 11 September 2008

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);
       }
Personal tools