Replace Method with Method Object

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m (Added an additional link, will probably expand this page using info from it later)
m (Reverted edits by Ebybymic (Talk); changed back to last version by Brett Ward)
 
(One intermediate revision by one user not shown)

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