views:

61

answers:

4

I'm familiar with the basics, such as "Extract Method." But that is about all that I use. What others are there? This can include refactoring tool features and also macros that you write yourself.

+3  A: 

From Resharper

  • The safe Rename feature.
  • Member/Variable highlighting.
  • On-the-fly Error Detection
  • Importing Namespaces

Also, a very nice Macro to use (this will also get you into creating your own)

Visual Studio Macro: Collapse Solution Explorer

A macro that collapses all the tree nodes in the solution explorer...

This is very usefull in larger solutions.

astander
+1  A: 

In addition to the ones @astander mentions, I use Convert Local Variable to Field (and vice versa) with some frequency. And when I need it, Pull Up (that is, make a method on a subclass be a method on the superclass instead) is REALLY nice to have.

LH
+2  A: 

Currently I use IntelliJ IDEA, most frequently

  • Rename (it can also rename getters/setters, and references in comments, literals and even non Java files like Hibernate mapping files)
  • Introduce variable / constant / field / parameter
  • Inline variable / constant / field
  • Extract Method, of course (the mother of all refactorings)
  • Change method signature (very useful)

And then there are a lot more which are needed less frequently, but when they are needed, they are needed badly:

  • Extract interface / superclass / class
  • Move method / class

Although Rename looks sort of trivial, it is still the most important of all. Finding good and better names for my program elements is a constant activity. Good names can make an enormous difference in the readability of a program.

OTOH the archetype of refactorings is Extract Method, because that is far more tricky to automate right. There can be lots of pitfalls, like possible name clash with a supertype method (or even worse: inadvertently overriding one), in/out parameters etc. So this has been a sort of threshold test for automated refactoring tools for long, although, I believe, by now the common ones tackle it well.

Péter Török
A: 

In IDEA in addition to what Péter Török mentioned I use a lot of:

  • Pull members up
  • Push members down
  • Safe delete

And some useful code generation (implement method, override method, generate constructor).

artemb