Refactoring, Rails, and “Coding Ruby Correctly”

Yesterday's blog post certainly generated a boat load of feedback, which I'm going to group into a few different tongue-in-cheek categories:

  • Refactoring isn't a problem, just refactor everything yourself by hand, or write a refactoring tool yourself.

If I had the time, I would. Refactoring by hand is what I'm doing now on a daily basis, because I don't really have any other choice. Thus the request for better tools.

Which brings up a tangentially related point. Why is it that whenever someone asks for better tools it's because they're lazy? I think that we can all agree that it sucks to use an axe to chop down trees when you've used a chainsaw before. From now on, comments of the form "just use grep to do it" will only be accepted from those of you who program on mainframes and walk everywhere, simply because you remember the good old days before we had these fancy cars and trains to move us around.

  • You must be coding Ruby incorrectly.

When making this comment, please point out the web page that shows how to write Ruby correctly. I have multiple Ruby webapps in production, I worked at Thoughtworks and I'm currently working with Pivotal Labs, two of the foremost Ruby consultancies, and no one has told me or my team that we're writing things incorrectly. However, I have an open mind and I'm willing to learn more about this topic.

  • You can't just throw together Ruby code without tests, that's why you're running into problems.

Aren't you going to have this problem with any language? Where did I imply that this was something that we were doing? Anyway, 'rake stats' says:

Code to Test Ratio: 1:2.8

So I don't think that's the problem.

Seriously though, It's all a bit academic. If you asked me what framework I would use if I was going to start building a new webapp tomorrow (and told me that I couldn't use Seaside) I would still choose Rails. It's still the best tool for lots of jobs out there. Pointing out some of it's deficiencies doesn't make that any less true, despite what some people seem to think.

Tiresome, Tedious Bullshit (on Rails)

In his post The Business Advantage of Rails, Giles Bowkett writes:

What makes programmers happy? Elegant systems which make them productive and take tiresome, tedious bullshit out of their daily lives.

People who get tiresome, tedious bullshit out of their way forever are great people to work with. Conversely, tolerating tiresome, tedious bullshit without ever fixing it is absolutely not a character trait you want your hiring process to be biased in favor of.

which sounds like a good idea, except that a lot of programming on a real application, no matter if you do it in Ruby, or Visual C, or COBOL, ends up being a lot of tiresome, tedious bullshit.

Which brings me to something that I've been thinking a lot about lately. At CDD we have a pretty complex Rails app, (as one of the consultants that we're working with said, "I've worked on a dozen Rails apps, and this is about 4 times bigger and more complex than any of them") and as our application gets bigger and bigger I'm starting to see more and more complexity and problems crop up. I feel like we're walking up the same old curve to all of the standard problems you run into when programming a webapp in any language (object model too big to be easily understood, code is getting less and less cohesive, etc). It may have taken a little longer to get there, but I'm pretty sure that we're going to end up in the same place.

Which leads me to another problem. The easiest solution to a lot of these problems, in my experience, has always been to refactor the code. That's what I always ended up doing with Java apps of this size back in the day. Unfortunantly, the state of Ruby refactoring tools, and I'm putting this as nicely as I possibly can, sucks. Even something as simple renaming a class tends to be far more painful than it needs to be.

So the big question now is, have we (and perhaps we're the first team to do this, as I haven't heard much about it from others) finally hit the point where the cost of maintaining our code in Ruby is higher than the savings by writing it in Ruby in the first place? I'm not willing to answer yes to that question yet, but I am starting to see more and more places that have me pining for for the good old days of IntelliJ, with all of the great things it does to make your life easier. It's easy to forget about the amount of tiresome, tedious bullshit that great tools can help us avoid, at least until you start running into that same old bullshit.