David Roundy <droundy@xxxxxxxxxxxx> writes:
>> As Kevin already explained, it is not so simple. To do the above
>> refactoring, you have to:
>> - change the uses of both com.mklooster.vehicles.Automobile and
>> Automobile, in the latter case not all uses (e.g., not
>> those referring to carwash.util.Automobile);
>> - rename the file Automobile.java to ICar.java, and move it
>> to a different directory;
>> - change/add related import statements.
>> So this really is language-dependent, and not simple search-and-replace.
>
> Yes, but it can at least be approximated by a set of existing darcs
> patches.
>
> darcs mv Automobile.java ICar.java
> darcs replace com.mklooster.vehicles.Automobile \
> com.mklooster.interfaces.ICar *.java
> darcs replace Automobile ICar [files that don't use carwash.util]
> [fix by hand any files using both carwash.util and com.mklooster.vehicles]
I think that's the correct approach, implement refactorings in terms of darcs
patches rather than the other way around. The benefit there is that a
refactoring browser would do language specific stuff, and save the results in
terms of patches any client could apply. (maybe this would be a fun HaRe
extension)
But, I don't know if the existing set of darcs patches are enough to implement
refactorings. ( Bill Opdyke's thesis could probably tell you for sure. )
I've mentioned that darcs is much like a refactoring browser before, I would
very much like to see this happen. It would be wonderful to track source past
refactorings.
Dr. Don Roberts discussed 'reversible' refactorings in his thesis
( http://st-www.cs.uiuc.edu/~droberts/thesis.pdf ) on the
original refactoring browser. His conclusion was that a refactoring can only be
proven to be reversible if all of your unit tests pass both before and after a
refactoring.
I haven't kept up with the latest in the refactoring community, but I'd be
surprised if that's changed.
Anyways, good places to check out for refactoring info:
Haskell Refactorer: http://www.cs.kent.ac.uk/projects/refactor-fp/
Refactoring homepage: http://www.refactoring.com/
Oh, for other semi-related info, Charles Simonyi/Microsoft Research's
Intentional Programming system stored source code as parse trees, and
considered a source language such as Haskell/Python/etc just one way to view
the parse tree. The idea was that I could write a Haskell program, save it into
the IP system, and you could load it as a Python program. If you're interested
in this sort of stuff, it's worth reading about.
There's a lot more related info, but this message has gone off-topic already.
--
Shae Matijs Erisson - 2 days older than RFC0226
#haskell on irc.freenode.net - We Put the Funk in Funktion
10 PRINT "HELLO" 20 GOTO 10 ; putStr $ fix ("HELLO\n"++)
|