What exactly should we learn from Active Record?

I read an interesting post the other day titled We should learn from Active Record. While Active Record does help facilitate the quick and dirty, it has a high reliance on the database structure. Your code and database layer essentially one in the same and I’m not sure I like this approach. This is especially true if you’ve had to deal with a crappy database model to begin with.

I’m a fan of type safety and the ActiveRecord approach is a step backward in that regard. The nice thing about Hibernate, and other ORM tools, is that your object model doesn’t have to be a one to one mapping of your database model. In fact, it can be quite different. An single table might map to several different, type-safe objects. Taking Bruce’s Person example, we may have multiple types of Address‘s such as HomeAddess, BusinessAddress, ect. Now suppose that you also have a Company entity which can also have an Address, but it would need to of type BusinessAddress. By defining strongly typed objects to represent our business data, we won’t mistakenly pass a HomeAddess to a Company.

Granted this is a slightly crappy exmaple, I think it kind of gets the point across. If you need a quick and dirty web app up and running quickly, why not just use Ruby on Rails? It’s great for that sort of thing. Do we really need a Java implementation of Active Record?When it comes to planning out a large scale application, I don’t see this sort of RAD approach offering much value long term. The ORM approach abstracts your DB layer from code, so if one layer has to change “it can be” isolated to a degree. But that’s just my opinion.

2 thoughts on “What exactly should we learn from Active Record?

  1. I don’t necessarily object too heavily about high reliance on the database, although I go back and forth on that one. I am fascinated by RoR, though, am eager to learn more, and am really irritated that my Amazon “2-day shipping” for the Agile Development with Rails book is taking 5 days.

    On the other hand, the RoR folks seem generally happy with MySQL. And the use of MySQL for anything serious tends to make me queasy. (Yes, Oracle is far, far too expensive, but it’s a fantastic DBMS.)

    Like

  2. I don’t necessarily object too heavily about high reliance on the database, although I go back and forth on that one. I am fascinated by RoR, though, am eager to learn more, and am really irritated that my Amazon “2-day shipping” for the Agile Development with Rails book is taking 5 days.

    On the other hand, the RoR folks seem generally happy with MySQL. And the use of MySQL for anything serious tends to make me queasy. (Yes, Oracle is far, far too expensive, but it’s a fantastic DBMS.)

    Like

Comments are closed.