When I started using it, I spent about two hours refactoring at my old pace. I would do a refactoring, then just kind of stare off into space for the five minutes it would have taken me to do the refactoring by hand, then do another, stare into space again. After a while, I caught myself and realized that I had to learn to think BiggerRefactoringThoughts, and think them faster. Now I use probably half and half refactoring and entering new code, all at the same speed (I should instrument to measure this). --KentBeck
Discussion about using shell tools to rename symbols moved to ReadWriteGrep
... area := aRectangle right - aRectangle left * (aRectangle bottom - aRectangle top). ....I select the statement to the right of the assignment and "extract method", naming the new method areaOf:. Now I have:
... area := self areaOf: aRectangle. ...Now I notice that aRectangle cares a lot more about this message than I do, so I "move to component" and choose aRectangle (other possible choices are my instance variables). The type inference stuff generally does a great job of determining the class or classes of aRectangle, or I can type the classes in. I choose "Rectangle", and name the new method "area". Now I have:areaOf: aRectangle ^aRectangle right - aRectangle left * (aRectangle bottom - aRectangle top)
... area := self areaOf: aRectangle. ...Now, areaOf: isn't doing me much good, so I go to the original method, select "areaOf:" and "inline method". Now I have:areaOf: aRectangle ^aRectangle area
Rectangle>>area ^self right - self left * (self bottom - self top)
... area := aRectangle area. ...Now I can imagine extracting "self right - self left" into "width", etc.Rectangle>>area ^self right - self left * (self bottom - self top)
The best thing about Refactory is how safe it is. As long as you don't manually edit the source code, you are nearly guaranteed (modulo things like choosing the wrong class for a "move to component") that you won't change the semantics of the program. The more I use it, the more aggressive I am slamming logic around until it makes sense.
Some other cool tricks:
-- KentBeck
'' I found myself with a lot of longerfaces once when I did this. -- AnonymousCoward ''
... and if the "i" being replaced above were in a quoted string e.g
String name = String("Brat Simpson");you'd get
StrminimalElementIndexng name = StrminimalElementIndexng("Brat SminimalElementIndexntmpson");You'd at least need to do lexical analysis to work out which lexemes need to be renamed (and apply the correct kind of substitution.) -- DafyddRees
http://st-www.cs.uiuc.edu/~droberts/tapos/TAPOS.htm
It does not just guess. It looks for special cases. Almost always one of the special cases applies. But sometimes it will tell you that it cannot perform a refactoring.
We originally thought that the lack of static type-checking would make it hard to build a refactoring browser for Smalltalk. Lack of type information is a disadvantage, but the advantages of Smalltalk made it a lot easier to make a refactoring browser for Smalltalk than it would have have been for C++ or Java.
-- RalphJohnson
I think it would be doable for Java. A Refactoring Browser that would work for the whole C++ language, and not some sane subset, would probably be AiComplete. Just think of all the possibilities for creative use of macros and templates. -- StephanHouben
I use emacs and JDE quite a lot for writing Java code. Maybe it would be possible to use Emacs Lisp to write refactoring utilities. I might have a go at it when (if) I have the time. -- BernardMichaelHurley
Actually, there are a few refactoring tools available for Java... see RefactoringBrowserForJava. However, these tools support only a small portion of the refactorings available in the original RefactoringBrowser for Smalltalk.
I'm quite new to Smalltalk myself (downloaded VisualWorks just last week), but as I understand it, any implementation of Smalltalk includes a complete development environment in which all code is edited, and the RefactoringBrowser runs inside this environment. There are some interesting technical reasons for this, but I'm afraid I don't understand them well enought to explain at all coherently--perhaps some more experienced Smalltalker could help?
Has there been any work in refactoring browsers for functional languages such as CommonLisp? It seems that the existence of closures would make operations like add/remove parameter quite difficult to perform safely in the general case, and difficult even to be sure of the safety of.
check out EclipseIde http://www.eclipse.org, IntellijIdea http://www.intellij.com/idea
Speaking of which, how do the refactoring capabilities of EclipseIde and IntellijIdea compare to RefactoringBrowser?
This page mirrored in WikiPagesAboutRefactoring as of July 17, 2004