Automated Refactorings in RubyMine

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.

Rename

When the name of a variable, method, or class doesn’t explain its purpose, rename it with shift + F6.

Extract Method

Inline Variable or Method

Additional Refactorings

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 ack and sed, then it’s time to upgrade to an IDE.