Replace Method with Method Object

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m (Reverted edits by Ebybymic (Talk); changed back to last version by Brett Ward)
 
Line 14: Line 14:
 
[[image:replace.gif]]
 
[[image:replace.gif]]
  
>== Additional Resources ==
+
== Additional Resources ==
 
  * [http://sourcemaking.com/refactoring/replace-method-with-method-object SourceMaking.com]
 
  * [http://sourcemaking.com/refactoring/replace-method-with-method-object SourceMaking.com]
 
  * [http://www.c2.com/cgi/wiki?MethodObject Ward's Wiki: Method Object]
 
  * [http://www.c2.com/cgi/wiki?MethodObject Ward's Wiki: Method Object]
 
----
 
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 
----
 
=[http://osadydenexe.co.cc UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY]=
 
----
 
=[http://osadydenexe.co.cc CLICK HERE]=
 
----
 
</div>
 

Latest revision as of 03:23, 25 November 2010

You have a long method that uses local variables in such a way that you cannot apply Extract Method.


   //class Order...
   double price() {
       double primaryBasePrice;
       double secondaryBasePrice;
       double tertiaryBasePrice;
       // long computation;
       ...
   }

Turn the method into its own object so that all the local variables become fields on that object. You can then decompose the method into other methods on the same object.

Replace.gif

Additional Resources

* SourceMaking.com
* Ward's Wiki: Method Object
Personal tools