- Rename method
Rename Method is a
refactoring that changes a name of a method into a new one, that better reveals its purpose.To have clearer, more understandable code, programmers would optimally want to change method names to reflect exactly what the method does. For example:
public int foo(int x){ return x+1; }
would be better renamed as:
public int addOneTo(int x){ return x+1; }
The function operates the same, but is now more easily readable for developers looking through the code.
Martin Fowler lists this as one of his refactorings at [http://www.refactoring.com refactoring.com] .Take care
Although it seems to be very easy to change a method name, you can break code, if you don't keep the old method calling the new one. Don't delete the badly named old method, before all callers are changed.
If you have provided an API including the old method, you cannot delete it anyway. In this case you use actually the "Copy Method" refactoring".
:"Java 5.0 provides the annotation @Override to protect against mistakes like this."
External links
* [http://www.refactoring.com/catalog/renameMethod.html Rename Method page at refactoring.com]
* [http://www.refactoring.com/catalog/index.html Refactoring Catalog]
Wikimedia Foundation. 2010.