[Catalyst] What value does an ORM add?

Matt S Trout dbix-class at trout.me.uk
Thu Jun 8 18:01:53 CEST 2006


Steve Atkins wrote:
> Not intending to start any sort of rancorous discussion, but I was  
> wondering whether someone could illuminate me a little?
> 
> I'm comfortable with SQL, and with DBI. I write basic SQL that runs  
> just fine on all databases, or more complex SQL when I want to target  
> a single database (ususally postgresql).
> 
> What value does an ORM add for a user like me?
> 
> Some ORMs provide a single interface to the underlying datastore, so  
> allow you to cache information in the ORM, as long as you're the only  
> app accessing the underlying datastore.
> 
> Higher level modules (authentication, say) can target the ORM API and  
> not need to worry about database-specific details (although they  
> usually use such simple SQL that they could get the same independence  
> by using DBI directly it's still a decent implementation choice).
> 
> But that seems to be about it.
> 
> I know that I don't need to use an ORM with catalyst - I can use DBI  
> perfectly well, or even a hybrid system where my code uses DBI and  
> other modules use an ORM. But there's so much excitement about ORMs  
> that I have to wonder whether I'm missing some big concept about  
> them, and there's something they offer that makes development quicker  
> even for someone fluent in SQL.

Hint: most ORM authors are pretty fluent in SQL, and we still use 'em :)

The main thing is being able to encapsulate the queries, database structure 
and logic behind an object-level API that outside code can talk to. You can do 
this yourself pretty easily, but then you end up writing the same simple glue 
code again and again and again.

ORMs aren't really IMO anything *desperately* exciting - they're just a good 
way to get the boilerplate/glue stuff done for you, ease programmatic SQL 
generation, and generally save repeated wheel re-invention. It's basically on 
the same principle that it wouldn't be *that* hard to built half a 
Catalyst-ish thing atop raw FCGI/mod_perl/whatever on every project - but it's 
much much less hassle to just use a library that already does it for you.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list