Loading Blog Search...

Tuesday, September 27, 2005

[SoftwareRec]: Some knowledge about refactoring

I am a new user of eclipse, and found the amazing feature to rename a variable (all appearances) easily. This feature is in the "Refactor" menu. Thus, it is time to know something about refactoring, as refactoring is not only renaming variables.
Refactoring is a powerful technique for improving existing software. When a system's source code is easily understandable, the system is more maintable, leading to reduced costs and allowing precious development resources to be used elsewhere. At the same time, if the code is well structured, new requirements can be introduced more efficiently and with less problems. These two development tasks, maintenance and enhancement, often conflict since new features, especially those that do not fit cleanly within the original design, result in an increased maintenance effort. The refactoring process aims to reduce this conflict, by aiding non destructive changes to the structure of the source code, in order to increase code clarity and maintainability.
Here are some example refactoring features:

Rename
A method, variable, class or other java item has a name that is misleading or confusing. This requires all references, and potentially file locations to be updated. The process of renaming a method may include renaming the method in subclasses as well as clients. On the other hand, renaming a package will also involve moving files and directories, and updating the source control system.
Move Class
A Class is in the wrong package, it should therefore be moved to another package where it fits better. All import statements or fully qualified names referring to the given class need to be updated. The file will also have to be moved and updated in the source control system.
Extract Method...(for more info)

No comments: