Mainstream D Programming

David Brown dlang at davidb.org
Sun Oct 14 12:05:06 PDT 2007


On Sun, Oct 14, 2007 at 03:25:22PM -0200, Ary Manzana wrote:

> Please tell me the steps you perform to do the refactor... Say, for 
> example, you are renaming the name of a method of class A, and suppose 
> there is another class B with the same method name (but you don't want to 
> change B's method's name).

I'd change the method name, and let the compiler tell me where the method
invocations are.  That's why I use a strongly typed language, and things
like the 'override' keyboard are useful.  My editor will then take me to
each erroneous invocation where a simple keypress will perform the rename.

My general experience is that people who use refactoring tools overestimate
how beneficial they are, and people who don't underestimate how useful they
are.

The problem is that when one uses a specific-focus refactoring tool, they
are limited to the transformations that the authors of the tools have
thought of (which is still a very useful set), but without the
general-purpose text transformations available in a good programmer's
editor, one can easily miss other types of refactoring that are also quite
useful.

BTW, I do this kind of refactoring all of the time.  Having to look at each
change has caught many other things to clean up as well, that I would have
missed if a tool automatically renamed everything.  I think reviews should
be looking at each change anyway.

Dave



More information about the Digitalmars-d mailing list