You Wanted More Refactorings?

... here they come! The refactoring team is working on many experimental refactorings at the moment. You can download them from the development update center of 4.2. You can try these features out and file bugs, send recommendations, etc. They're not for production use yet - no quality is guaranteed at them moment (it's the bleeding edge development).

The new refactorings are:
  • Pull up - pulls the selected method to the parent class of current class.
  • Push down - pushes down the selected method to the class subclassing current class.
  • Extract method - creates a method from selected lines of code and calls the method.
  • Introduce variable - introduces a new local variable to simplify a complex expression.
  • Copy class - creates a copy of current class.
  • Convert anonymous class to inner - converts selected anonymous class to inner class.
More refactorings are being prepared, for details take a look the following page:

Issues for these experimental modules should be filed against refactoring module with status whiteboard "experimental".

External contributers wanted! Do you want to learn more about NetBeans and take the challenge to develop a refactoring feature? Contact refactoring team at dev-AT-refactoring-DOT-netbeans-DOT-org. They'll guide you through the development and you will be able to show off that you created your own refactoring in NetBeans.

Flash demo of new refactoring features (incl. speech)

Roumen, thanks for the update on refactoring. It is very heartening to see this progress. Hopefully soon I can contribute to all this effort to make NB the best IDE.

I have the following Refactoring wishlist for Netbeans:

1. Safe Delete (deletes a method/class only after checking all code that calls this method/class instance; offers user a chance to say no to the operation)
2. Safe Move (moves a class from one package to another only after checking all code that calls this class/instance and changing their import statements. Changes the package declaration of this class appropriately.) The present Move refactoring does not do a good job of this.
3. Use interface where possible : many times out of habit we do not use interface when declaring or assigning a variable: ex. Hashtable a = new Hashtable(), could be written as Map a = new Hashtable(). This refactoring automatically changes all refs of implementation classes to interfaces.
4. Generify: automatically converts non-generics usages in code to generics compliant code. ex. List a = new ArrayList() containing Strings is automatically changed to List<String> a = new ArrayList<String>()
5. Renaming a class/method safely : Many times we start writing a class/method only to realize that the name should be better. This refactoring not only changes file name but also replaces all areas in code that call or refer to this class's instance or method.
6. Finalize: Checks a class and adds the final keyword to any variable that can be made final. 6. Optimize for Performance : Checks a class for poor performing code blocks based on well established norms, and makes changes that will improve performance of this code.
7. Convert to Enhanced For Loop : Converts all old-style For loops into the Java 5 style Enhanced For Loop.
8. Extract interface: helps create an interface from a class that has already been written. Offers user a chance to specify which methods are to be defined in the interface.

Posted by Shreedhar on květen 15, 2005 at 11:38 dop. CEST #

Shreedhar, thank you for your comments. I have checked the refactoring specs and 1, 4 and 8 are already covered by a spec (safe delete is currently being developed by a contributor). The others don't seem to be covered yet, so I will send your comments to the refactoring developers. We will be glad to see you joining the effort!

Posted by Roman Strobl on květen 15, 2005 at 12:47 odp. CEST #

A small correction. People should not contact Jan Becicka directly. If you are interested in contributing, contact us at

Posted by Martin Matula on květen 16, 2005 at 05:53 dop. CEST #

Thanks Martin, I'll change it in the text. Second correction is that Copy class action should be invoked from Projects view, not from editor.

Posted by Roman Strobl on květen 16, 2005 at 06:28 dop. CEST #

My wishes: \* insert selected code into a try-catch statement \* add a catch statement to an existing try-catch

Posted by Valere Dejardin on květen 17, 2005 at 02:47 dop. CEST #

> My wishes: \* insert selected code into a try-catch statement \* add a catch statement to an existing try-catch

We plan to do this for NB 4.2. See this specification:

Posted by Jan Becicka on květen 17, 2005 at 04:34 dop. CEST #

I would like the enhanced for loop, it would be nice to have. Go for it Shreedhar.

Posted by Daniel MD on květen 19, 2005 at 09:16 odp. CEST #

Post a Comment:
Comments are closed for this entry.

Roman Strobl


« červenec 2016