Refactoring is the process of changing the internal structure of code without changing its external behavior. Successful refactorings involve taking very small, sometimes tedious, steps. Fortunately, many refactorings are simple enough to be automated. In this post, we’ll look at automated refactorings in RubyMine on OS X.
When the name of a variable, method, or class doesn’t explain its purpose, rename it with
shift + F6.
Help explain complex expressions by introducing variables with
command + option + V.
Move related logic into a separate method with
command + option + M.
Inline Variable or Method
Inline variables and methods that don’t increase clarity with
command + option + N
Less frequently used refactorings, such as extracting a superclass or module, are available from the “Refactor This…” dialog,
control + T.
Automation Makes a Difference
Refactoring is a significant part of everyday development. It’s the final step in TDD’s mantra of red, green, refactor. We often refactor inherited code to help us better understand it. Automating refactoring encourages more refactoring. If a simple class rename involves
sed, then it’s time to upgrade to an IDE.