Leaky ORMs

The other day I posted a link to this article on our company gmail, as we like to do here, to spark a Friday afternoon debate. One of my fellow devs, the most excellent @knocte came up with this reply so I thought I’d post it here:

“That’s a good article.

ORM pattern is always going to be leaky* because it’s just a workaround to a bigger problem: impedance mismatch between the relational model of data and the object-oriented model of our languages.

Until we have a language that has the relational model built-in as first class citizen**, or until we use an object-oriented database (IMO better than the document-oriented ones), we’ll have to live with this abstraction (as in, I prefer to have a leaky abstraction than not having any abstraction).

In the end having a leaky abstraction is not so bad anyways: you need to understand the inner details of what is being abstracted, not treat it just like a black box. With that you get a lot of side benefits: you understand the bigger picture, you will know at what level of abstraction you will need to apply a fix for a certain problem, etc.

I would apply this quote from Joel not only to code generators but to every abstraction:

Code generation tools which pretend to abstract out something, like all abstractions, leak, and the only way to deal with the leaks competently is to learn about how the abstractions work and what they are abstracting. So the abstractions save us time working, but they don’t save us time learning. … Ten years ago, we might have imagined that new programming paradigms would have made programming easier by now. Indeed, the abstractions we’ve created over the years do allow us to deal with new orders of complexity in software development that we didn’t have to deal with ten or fifteen years ago, like GUI programming and network programming. And while these great tools, like modern OO forms-based languages, let us get a lot of work done incredibly quickly, suddenly one day we need to figure out a problem where the abstraction leaked, and it takes 2 weeks.

So whenever you want to avoid ORM because it’s a leaky abstraction, think first if you want to be 10 or 15 years ago behind.

* Let’s say “moderately leaky” to put it in Joel’s terms, as for him all non-trivial abstractions are leaky to some degree.

** No, LINQ is not that.”

Great stuff!!

See also:


About Greg Sochanik

a .net software developer at 7digital, on the silicon roundabout. Living in angel with his lovely wife, little baby boy and mischievous cocker spaniel. Follow me on twitter @gregsochanik
This entry was posted in Software Development and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>