I'm a Java programmer who started programming Ruby on Rails one year ago. I like the language, rails itself and the principles behind them. But something that bothers me is that Ruby programmers don't seem to refactor.
I noticed that there is a big lack of tools for refactoring in Ruby / Rails. Some IDE's, like Aptana and RubyMine seem to offer some very basic refactoring, but nothing really big compared to Eclipse's Java refactorings.
Then there is another fact: most railers (even the pros) prefer some lightweight editors, like VIM or TextMate, instead of IDEs. Well, with these tools you just get zero refactoring (only regex with find/replace).
This leaves me this impression that rails programmers don't refactor. It might be just a false impression, of course, but I would like to hear the opinion of people who work professionally with ruby on rails.
Do you refactor? If you do, how do you do it,with which tools? If not, why not?
Refactoring is the craft of improving the design of an existing code without changing its external behavior. Just like with everything else, you get better at it with practice and continuous learning.
The best time to consider refactoring is before adding any updates or new features to existing code. Going back and cleaning up the current code before adding in new programming will not only improve the quality of the product itself, it will make it easier for future developers to build on the original code.
An IDE is more practical to construct for Java
Java's strict typing and documented grammar make it possible to write language-parsing IDE tools
Ruby's duck typing and documented-by-the-Yacc-source grammar make it quite difficult to do so.
An IDE is more needed for Java
Java's verbosity makes code-writing and code-rewriting tools desireable.
Ruby's extremely terse nature combined with the typically-no-type-declarations (of course they do appear inline with Type.new
) make such things optional.
Combining the two...
So the combination of really hard to write coupled with not actually needed results in the balance tipping in favor of people's favorite editors.
Giving up vi(1) for an IDE is something I would rather not do, but I do with Java because I need the IDE to write my interface implementations and such, and the fact that it parses Java makes it useful in code completion. Since with Ruby it can't and I don't need it anyway, I stick with vi(1) and TextMate.
Summary
Since you aren't buried in code, it's possible to refactor with a few reasonable edits. But while on the subject of "other Ruby developers", my Ruby question is: why does everyone (except me it seems) use function parens? Because in a few % of situations they are needed, and so the "inconsistency" is disturbing?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With