Archive

Posts Tagged ‘Extractions’

Refactorings – Extract Method

August 13th, 2010 Comments off

The Extract Method refactoring creates a new method from the selected code block. The selection is replaced with appropriate calling code to invoke the newly-declared method. The Extract Method is great when you need to turn a big, complex method into smaller, simpler ones. Small methods are much easier to maintain, and encourage code reuse, and also have the following advantages:

  • It increases the chance that other methods can use a simple method when the method is finely organized and well-formed.
  • It allows the higher-level methods to read more like a series of comments, which improves the code readability. Simple methods with good names comment themselves, and improve overall code clarity. Overriding also is easier when the methods are finely grained.

Read more…