Obie Fernandez: The Worst Rails Code You've Ever Seen!

Posted by Frank Oxener
on Sunday, June 15, 2008

Last Tuesday (10th of June) Obie Fernandez gave a presentation on the RubyenRails conference in Amsterdam about The Worst Rails Code You’ve Ever Seen.

To be honest he had some really bad examples, he showed us for example an user controller of 1131 lines (of pure FAIL)!!

But a lot of examples were more in the line of not knowing there is a better alternative in Ruby or a better alternative provided by the Rails framework.

Obie came with an example like this:


class Util
  def hash_values_as_array(hash)
    values=[]
    for key, value in hash
      values << value
    end
    return values
  end
end

(Of course, you can do the same with hash.values.)

I don’t think this is bad at all and I even think it happened to almost all of us. Most people working with Ruby On Rails were attracted by the power (and the beauty) of the Rails framework and had never worked with Ruby before (and most of the times had no or little experience with web development like myself). For a newbie it takes time to get used to and to find your way and understand the ins and outs of the language and the framework. And sometimes it is more simple or quicker to come up with your own little method like the example above. In fact, it’s a great way (or maybe the way) to learn a new language like Ruby.

The main point of Obie was that you need to learn the fundamentals, read some books and pair with senior people. All true, but it takes time and it’s more difficult for someone starting this year with Rails instead of let’s say 2005.

Rails is becoming a ‘big’ framework and if you know it really well (and keep up with all the new developments) it can make you really productive. But the learning curve is becoming steeper and steeper …....

If I look at available Rails jobs, everybody seems to look for a rails ninja, rock star, kick ass developer, killer rails developer, crazy rails hacker or even an inspiring Ruby god. I think they are difficult to find.

If you want my advise, find a place where they see your learning potential and don’t mind that you make mistakes like the ones Obie is talking about. It is all about learning by doing (and making mistakes along the way).

One more thing, Obie wrote The Rails Way, which is IMHO the best Rails book at this moment. At the end of his presentation Obie announced he is going to write a Rails Antipatterns book. I think this is not the right approach, please write a Rails patterns book, that is much more positive!

Workshop Ruby on Rails and Maglev

Posted by Frank Oxener
on Sunday, June 01, 2008

I was asked to give an introductory workshop in Ruby on Rails for an insurance company. An intranet application was build in Ruby on Rails for this company and now they want to have the knowledge to maintain the application themselves. So I organized a workshop in two sessions to touch on the basics of Ruby and Rails. And I have to say, it is not easy …. especially when this application has polymorphic and has_many :through associations… :-)

I myself started with Ruby on Rails in October 2005 (I had no experience with Ruby at all) and I remember it was straight forward, although it toke me a while to understand (for example) some of the magic of ActiveRecord (made possible by Ruby). But now 2,5 years later we have Rails 2.1 (since yesterday!) and it has a lot of new concepts and extra features and therefore I think it is a lot harder to get started. My preparation for this workshop made me realise that now it will take more time to really get acquainted with the full potential of Rails.

And to be honest, working every day with Rails, it still is a challenge to keep up-to-date with the new features in Rails (which seems to be added almost ‘every’ day) and all the new developments and innovation in the Ruby and Rails community. The day before yesterday I had never heard of Maglev or Mongrel-esi.....