If you could have only one refactoring, which would it be? Which refactoring could you least afford to give up?
To me the obvious answer is the rename refactoring. It's an activity that I do very frequently. In fact, the way I code is dependent upon my ability to do a rapid rename.
I try to follow Uncle Bob's mantra "never be blocked" at even the smallest granularities. I won't stew for more than a few seconds to derive a name for a class, field, method, or other identifier. Instead, I type. If my brain is really frozen, I'll surge forward by typing an "x" or the word "something." No worries--I usually think of a better name shortly thereafter. I then do a ctrl-1/rename, type the new name, press enter, and Eclipse completes the job for me very safely and quickly.
The name isn't final at that point. I'll continue to update an identifier's name as my understanding of what it represents gets refined (or changes).
Recently I committed myself to working more in-depth with Groovy. I'm happy with its improved simplicity, consistency, and expressiveness over the tedium that is Java. As always, I spent a while using Groovy's bare-bones tools (groovyc, groovyConsole, etc.) so that I understood them enough to survive if I had to. Done enough of that! Now I'm looking to my productivity experience by introducing an IDE, so I downloaded and installed the Groovy plugin for Eclipse.
Harumph, and that's even after ignoring (a) a couple bizarre errors that I received because I hadn't forced a clean and (b) the obtuseness of the exceptions. No, the big harumph is that there are no ctrl-1 or refactoring options anywhere to be found. I've heard IDEA is better (and hope to try it out here soon), but as I understand, the rename challenge will never be completely resolved: safe rename refactorings require type information. You can provide that in Groovy, but figure on most developers not bothering.
And for now, the Eclipse plugin isn't even trying. I created a private, typed field--something for which a refactoring operation could be very safe--but now I can't change its name without resorting to search/replace. The fact that I may need to discard my newer programming style of "continual rename" makes me feel dirty.
Even with some forethought, programmers will always choose some names that end up less than ideal. And since developers are notorious for not changing things that might break, the poor names will remain as long as the IDE can't do it safely. Maintenance costs will be higher.
The main point of my post is that after years of using a strongly-typed language, I am now resisting languages like Groovy and Ruby to an extent. Not because I'm worried about the defects that could happen at runtime that wouldn't otherwise-my use of TDD generally means that's not an issue. Instead, my complaint is about lack of productivity, and worse, the decreased amount of refactoring that will likely result.
The question is, do benefits accruing from the increased simplification of the code outweigh the negatives of more difficult refactoring?
February 2004 March 2004 May 2004 September 2004 October 2004 January 2005 February 2005 September 2005 October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 June 2006 August 2006 January 2007 February 2007 March 2007 April 2007 September 2007 October 2007 November 2007 December 2007 January 2008 February 2008 March 2008 April 2008 May 2008 June 2008 July 2008