Replace Method with Method Object

From CSSEMediaWiki
Revision as of 00:11, 7 August 2009 by Matthew Harward (Talk | contribs)
Jump to: navigation, search

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

Personal tools