CSC/ECE 517 Fall 2009/wiki1a 9 mk: Difference between revisions
Wikimaster (talk | contribs) |
Wikimaster (talk | contribs) |
||
Line 96: | Line 96: | ||
differences. | differences. | ||
The approach for addressing the latter two of these issues was by providing automated assistance, which help to increase the speed of program restructuring. | The approach for addressing the latter two of these issues was by providing automated assistance, which help to increase the speed of program restructuring. | ||
William F. Opdyke, in one his other research found that, object-oriented programming makes program components more reusable, but in the long run reusing the design of an application is more important than reusing the implementation of any | William F. Opdyke, in one his other research found that, object-oriented programming makes program components more reusable, but in the long run reusing the design of an application is more important than reusing the implementation of any |
Revision as of 16:16, 7 September 2009
Research in Refactoring Tools
Refactoring
Refactoring is the process of modifying existing source codebase in a structured and incremental way while preserving its external behavior. This process preserves the functionality of the program without introducing new bugs. Refactoring also promotes reuse of the existing codebase for other purposes thus increasing code reusability.
Overview
One of the most important aspect of any software meant for real world applications is its ability to evolve.Many surveys conducted by major software organizations have reavealed that, maintenance is the major part of the total Software Development life cycle. Maintenance of the code would be much less difficult, if the code has the capacity to evolve, where in refactoring comes into picture. Refactoring improves the internal structure of the codebase keeping the behaviour/functionality of the program same as before and therefore any program which meets its specifications before refactoring will continue to meet those specifications even afterwards. Refactoring can be done on any codebase and it is a general set of operations. Hence it comes with preconditions which specifies under what circumstances refactoring can be performed, also with the conformation that the dependency graphs are unchanged even after the refactoring is performed.
Current Automated Refactoring Tools
Features of some Refactoring Tools
Refactoring can be grouped into three broad categories.
1. Changing the name and physical organization of code, including renaming fields, variables, classes, and interfaces, and moving packages and classes.
2. Changing the logical organization of code at the class level, including turning anonymous classes into nested classes, turning nested classes into top-level classes, creating interfaces from concrete classes, and moving methods or fields from a class to a subclass or superclass.
3. Changing the code within a class, including turning local variables into class fields, turning selected code in a method into a separate method, and generating getter and setter methods for fields.
Given below is an example of Refactoring, demonstrating how it enhances reusability
void displayValues() { double averageSalary = 0; double totalCars = 0; for (int i = 0; i < people.length; i++) { averageSalary += people[i].salary; totalCars += people[i].carCount; } averageSalary = averageSalary / people.length; System.out.println(averageSalary); System.out.println(totalCars); }
The refactored code:
void printValues() { System.out.println(averageSalary()); System.out.println(totalCars()); } private double averageSalary() { double result = 0; for (int i = 0; i < people.length; i++) { result += people[i].salary; } return result / people.length; } private double totalCars() { double result = 0; for (int i = 0; i < people.length; i++) { result += people[i].carCount; } return result; }
Java Refactoring Tool, Eclipse
Ruby Refactoring Tool, Aptana
.NET Refactoring Tool, Visual Studio IDE
Academic Underpinnings behind the refactoring Work
William F. Opdyke, who is one of the important person behind the success of refactoring, was the first to think in the lines of "why people could be reluctant to refactor their software given refactoring improves the software.They found mainly four reasons
1. "I don't understand how to refactor."
2. "If the benefits are long-term, why exert the effort now? In the long term, I may no longer be with the project.”
3. "Refactoring code is an overhead activity; I’m paid to write new features."
4. "Refactoring might break the code."
The first two issues were addressed by defining a taxonomy of refactoring, which helped both in short term as well as in long term. For example, when defining a new feature that is a variant on an existing feature, one can define classes (usually abstract classes) that capture the common behavior, and use subclassing to capture the feature differences. The approach for addressing the latter two of these issues was by providing automated assistance, which help to increase the speed of program restructuring.
William F. Opdyke, in one his other research found that, object-oriented programming makes program components more reusable, but in the long run reusing the design of an application is more important than reusing the implementation of any one of its components. An important object-oriented technique to facilitate design-level reuse is an application frame- work, which is an abstract design of an application, consisting of an abstract class for each major component. The framework has following operations, all of which are self explainatory
1. Refactoring To Generalize: Creating An Abstract Super-class.
2. Refactoring To Specialize: Subclassing and Simplifying Conditionals.
3. Capturing Aggregations and Components.
Improvements Current Refactoring Tools need
Tools that help the programmers with selection should:
1. Be lightweight. Users can normally select code quickly and efficiently, and any tool to assist selection should not add overhead to slow down the common case.
2. Help the programmer overcome unfamiliar or unusual code formatting.
3. Allow the programmer to select code in a manner specific to the task they are performing. For example, while bracket matching can be helpful, bracketed statements are not the only meaningful program construct that a programmer needs to select.
Conclusion
Refactoring is an important part of software development and refactoring tools are critical to making refactoring fast and behavior preserving. In this paper, I have presented three new tools that help programmers avoid selection errors and understand violations of refactoring preconditions. Through a user study, I have demonstrated that these tools exhibit several qualities that improve the experience of refactoring, help programmers correctly identify problems with a proposed refactoring, and increase speed of the refactoring process. I hope that these qualities will be adopted by new refactoring tools, make tools more usable and thus more used, and eventually contribute to the production of more reliable, on-time software.