Refactoring Ruby

ArticleS.UncleBob.RefactoringParalysis:

"I've been working on on the Harry Potter problem in Ruby. I have a version that works, and now I'd like to refactor it. I'm using Text Mate as my 'ide'. I find myself in a state of paralysis. There I things I'd like to change, but I know the cost will be high, so I think and think about them instead of acting. This is not how I work in Java with IntelliJ. With IntelliJ I do my thinking by acting! I change variable names; I extract methods; I create and destroy base classes; in short I refactor madly. But in Ruby, without a good refactoring tool, I sit and stare at the code. I know what I have to do. I just have to break through the fear and start refactoring; and I will. But I was amazed at how intense the fear of changing code is when you don't have the appropriate tools. Jetbrains, or someone, you really have to make a refactoring tool for Ruby!!!"

The only apparent project on refactoring for Ruby is this. And it has not been updated for almost a year. Moreover, it uses Emacs which probably means that everything has to be done using lisp macros.

That said, the idea of writing a refactoring browser for Ruby is pretty interesting. And one that I have been thinking of (but not trying to do yet) for almost a year. There aren't that many refactoring browsers for dynamically typed languages. Smalltalk has one (and, mind you, was the first language to have a refactoring browser).

So I am going to gather some more information on this subject and propose this as a master's thesis to Prof. Johnson. After all, being with at this university with the pioneers of refactoring means that there is definitely going to be a lot of people with enough experience. And there is always Don Robert's thesis to help me get started.

I would also like to know the importance of a refactoring tool for a dynamic and agile language such as Ruby. All the latest refactoring tools concentrate on Java and C# both heavyweight languages in their own class. Last summer, I worked on Photran: A plug-in for Eclipse that supports the Fortran language and has some refactoring. Even though I did not work on the refactoring part, I can tell that it was really hard work. Even now, the parser for Fortran is not as fast as most people are used to.

Some possible problems I can definitely think of:

By the way, there definitely is interest in refactoring Ruby on the web:


comments powered by Disqus