You write a few methods, add a few columns, write some more methods,
add another table, and on we go.
And if you change your mind, you have to remove a few methods, flip over
to the db, remove a few columns, flip back to ruby, remove a class, flip
back to the db, remove the table....no?
Steve
···
-----Original Message-----
From: David Heinemeier Hansson [mailto:david@loudthinking.com]
Sent: Tuesday, May 03, 2005 4:50 PM
To: ruby-talk ML
Subject: Re: Ruby, Rails and now og
What I like about this is I can write and evolve my application with a
focus on objects and behavior, without thinking of what database, if
any, I might be using, or what tables, if any, I might need to create.
As I go along, I can easily add persistence to objects by adding a few
lines of code to the class def.
It helps avoid a lot of big upfront design.
Heh. This would of course only be true be under the assumption that you
had to create your entire schema before starting on the object- oriented
part of the domain model. Which is false, of course.
Active Record is imminently suited and created with special attention
for evolving designs. The Rails way of designing your schema is column
by column as they're needed by the domain model. I'll often times start
a new domain model with linked to a table with just a single column. A
person object birthed with just a name, for example.
The great thing about working column by column is that the "conversion"
from object to database is transparent and happens all the time. You
write a few methods, add a few columns, write some more methods, add
another table, and on we go. There's no build phase where the framework
generates SQL, which then has to be loaded against your database, and
which will destroy the test data you've been working with.
Object-to-SQL conversions have their place. One of them is the
capability of generating multiple flavors of SQL from a single
definition. Preventing big upfront design is something you do by
choosing to. It's unrelated to the choice between Object-to-SQL or
SQL-to-object.
--
David Heinemeier Hansson
http://www.loudthinking.com -- Broadcasting Brain
http://www.basecamphq.com -- Online project management
http://www.rubyonrails.com -- Web-application framework