Eclipse - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Eclipse Refactoring

Eclipse Refactoring

shape Introduction

This chapter Eclipse Refactoring demonstrate about the use of Refactoring tool. Refactoring allows user to rename methods or class, extract Functions and extract Constant. The mistakes done while programming like giving poor variables and method names or some code lines repeated couple of times can be changed using refactoring method without disturbing the entire code. Following are the concepts covered.
  • Refactoring
  • Refactoring in Eclipse

Refactoring

shape Description

Refactoring is defined as a restrained method for rebuilding an existing piece of code, modifying its interior structure without changing its outer behavior. Refactoring is a tool to automate behavior-preserving changes to source code and are not only extremely famous in light-footed advancement situations, but have been generally established as a foundation of the day to day software development. Eclipse offer a set of powerful refactoring’s to substantially increase development productivity. While built-in refactoring’s perform a large portion of the dull and errors such as renaming or moving software elements, sometimes the need emerges to build a custom solution to streamline repetitive tasks. Features Following are some of the features of using refactoring in Eclipse.

Refactoring in Eclipse

shape Description

A class or method used throughout the entire project can be renamed using the refactor tool. The refactoring make modifying the code easy for a developer by automatically updating all the required changes. In order to refactor the select class or method follow the procedure mentioned. Open a Java file -> select a method or class -> click Refactor menu -> select Rename as shown in the image below. Now, a dialogue box appears known as Rename Refactoring asking the user permission to rename the method, proceed by clicking OK button as shown in the image below. A dialogue box appears providing the new name option for renaming the selected method, click Preview button to see the changes as shown in the image below. Now, the dialogue box redirect and provide list of all the files that have been automatically changed and updated with the new method name and also provide comparison boxes before and after  the changes, proceed by clicking OK button in order to update the method name as shown in the image below.

Summary

shape Key Points

  • Refactoring method modify the interior structure of a code without changing the outer behavior of the code.
  • A class, method or variable name used throughout the project get renamed and updated automatically in using refactoring in Eclipse.
  • Refactoring method saves a lot of time in modifying a code and increase the productivity.