[rspec-users] RSpec makes me want to write better code

Mark Wilden mark at mwilden.com
Sat Sep 27 15:29:32 EDT 2008

On Sat, Sep 27, 2008 at 11:26 AM, Dan North <tastapod at gmail.com> wrote:

It seems these conversations come up time and again because Rails overloads
> the idea of "model". In a Rails app the model serves as both your domain
> model and your persistence strategy, because of the coupling inherent in the
> Active Record pattern.

Interesting. This coupling actually brought me to one of my first "a-ha!"
moment in Rails (similar to when I first learned about the ++ operator in
C). Finally, I thought, I don't have to do anything to set up the
butt-simple relationships between models and tables that are found (as you
say) in 90% of web apps (and other applications, too). Rails allows models
as complicated as you want, and it also allows you to do work in the
database when you need to (I know "find_by_sql" is a dirty word, but it
allows me to perform pivots on multiple tables of millions of rows, where AR
simply could not handle the SQL). But it makes the overwhelmingly common
case simple, and I like that.

So I've found that this model-db coupling to be a powerful feature of Rails.
I know it's saved me a lot of work, because I've had to do it manually so
many other times in the last 25 years. If it's not sufficient or appropriate
in any particular case, I don't have to use it.

I know this view puts me on the wrong side of the contest you speak of
(which I frankly didn't even know I'd entered). And yes, using Rails the way
I (and many others) do involves trade-offs. But the one trade-off it doesn't
require is with TSTTCPW, which is the guiding philosophy in everything I do.

I guess this makes me an AR pixie. :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080927/de002fa4/attachment.html>

More information about the rspec-users mailing list