Exforsys.com
 
Home Tutorials WebSphere
 

WebSphere V5.0 : Java Development - Use refactoring features

 

WebSphere V5.0 : Java Development - Use refactoring features

In this tutorial you will learn about WebSphere V5.0 : Java Development - Use refactoring features, Refactoring support, refactor actions, rename, Move, Pull Up, Modify Parameters, Extract Method, Extract Variable, Inline Local Variable and Self Encapsulate Field.



Refactoring support

The goal of refactoring (behavior-preserving program transformation) is to make a system-wide code change without affecting the behavior of the system. The JDT provides assistance for managing refactorings.

The JDT supports a number of transformations (e.g. Extract Method, Inline Local Variable) described in Martin Fowler's book "Refactoring: Improving the Design of Existing Code", Addison Wesley 1999.

When performing a refactoring operation, you can optionally preview all the impending changes resulting from a refactoring action before you choose to carry them out. Thus, you can execute a refactoring in one of two ways:


  • Refactoring with preview

In a controlled refactoring, you are notified of potential problems and are given a detailed preview of what the refactoring action will do.


  • Refactoring without preview

In a quick refactoring, the potential problem notification and preview are omitted. If a Stop problem is detected, the refactoring will be halted and a list of problems will be displayed.


Refactoring commands are available from the context menus of several Java views (e.g. Package Explorer, Outline) and editors.

Refactor context menu


Refactor actions

Refactor menu commands:


Refactor menu


Rename

Starts the Rename refactoring wizard: Renames the selected element and (if enabled) corrects all references to the elements (also in other files). Is available on methods, fields, local variables, method parameters, types, compilation units, packages, source folders, projects and on a text selection resolving to one of these element types.

Rename


Rename preview


Move

Starts the Move refactoring wizard: Moves the selected elements and (if enabled) corrects all references to the elements (also in other files). Can be applied on one or more static methods, static fields, types, compilation units, packages, source folders and projects and on a text selection resolving to one of these element types.


Pull Up

Starts the Pull Up refactoring wizard: Moves a field or method to its super class. Can be applied on one or more methods and fields from the same type or on a text selection resolving to a field or method.


Modify Parameters

Starts the Modify Parameters refactoring wizard. Changes parameter names and parameter order and updates all references to the corresponding method. Can be applied on methods with parameters or on text selection resolving to a method with parameters.


Extract Method

Starts the Extract Method refactoring wizard. Creates a new method containing the statements or expression currently selected and replaces the selection with a reference to the new method. You can use Expand Selection to from the Edit menu to get a valid selection range. This feature is useful for cleaning up lengthy, cluttered, or overly-complicated methods.


Extract Variable

Starts the Extract Variable refactoring wizard. Creates a new variable assigned to the expression currently selected and replaces the selection with a reference to the new variable. You can use Expand Selection to from the Edit menu to get a valid selection range.


Inline Local Variable

Starts the Inline Local Variable refactoring wizard. Replaces the references to the selected local variable with the variable's initializer expression and removes the variable.


Self Encapsulate Field

Starts the Self Encapsulate Field refactoring wizard. Replaces all references to a field with getting and setting methods. Is applicable to a selected field or a text selection resolving to a field.

Self Encapsulate Field



Self Encapsulate Field. Preview


Note: Refactoring commands are also available from the context menus in many views and the Java editor.


_____________
Author: Mikalai Zaikin. Please Click Here to visit Authors site for any updates and changes to the study notes.



Read Next: WebSphere V5.0 : Java Development - Use content assist function and declarations



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape