[Catalyst] What value does an ORM add?

Yuval Kogman nothingmuch at woobling.org
Thu Jun 8 18:09:50 CEST 2006


On Thu, Jun 08, 2006 at 08:33:56 -0700, 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?

Less glue code:

If you want to reuse generic code operating on your DB values you
usually lift data from the db into a hash or an object. An ORM does
that for you and the view can be naive about what the backend
actually is. As you said:

> 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 this goes deeper. I have sites running the same views for very
different models and it works beautifully because of polymorphism.

If you can mix LDAP, XML and DBI in the same app and the non model
components don't really care which source the objects are coming
from it's very easy to reuse code.


Easy relationships:

Creating, reading, updating and deleting simple relational data is
usually *greatly* simplified. ORMs like DBIx::Class make it feel
like you're working with set operations, not SQL.


Good behavior with no effort:

A typical ORM quotes all fields, prepares statements, connects at
the right time to the DB and it does all that without you having to
worry about it. This saves lots of boilerplate.

Type less:

Well, this one is obvious.

-- 
  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20060608/930e0ba6/attachment.pgp 


More information about the Catalyst mailing list