Refactorings – Inline Method
The Inline Method refactoring lets you move the method’s body into the body of its callers and remove the method declaration, if needed. Inline Method is helpful when you have a group of methods that seem badly factored. You can inline them all into one big method, and then re-extract the methods.
Another reason to use Inline Method is that sometimes you do come across a method in which the body is as clear as the name. Or, you refactor the body of the code into something that is just as clear as the name. When this happens, you should then get rid of the method.
There are two versions of this refactoring:
- Inline Method
- Inline Method (and delete)
The difference between the two is that the second one removes the source method, if appropriate.
The refactoring is available either on the source method name or the calling side.
Opposite
The opposite of this refactoring is the Extract Method refactoring.
Source sample code
Refactoring preview
Result
Please note the Version field below for this refactoring.
—– Products: Refactor! Pro Versions: 2011.1 and up VS IDEs: any Updated: Feb/17/2011 ID: R021