Skip to content

Extract Method

pavlospt edited this page Oct 24, 2014 · 1 revision

Following in my streak of extract refactoring, here is the one to extract a code block in a new method.

This thing is extremely useful. Whenever you encounter a method that is starting to become a bit complex, you can use this to safely extract a portion in another method. I say safely because the IDE won't make a silly copy-paste mistake like we might do.

Additional tip:

  • Once you are in the extracting dialog, you can change the visibility of the method and the parameter names.

Shortcut (Menu):

  • Mac: Cmd+Alt+M
  • Windows/Linux: Ctrl+Alt+M