Okay, I wasn't planning on having a Part IV of my series on "Architecture Dilemmas:O/R Mapping." (Part I, Part II, and Part III are available here. In addition, a single PDF file is also available.)
What prompted Part IV was my reading Ted Neward's blog on why he thinks O/R mapping is The Vietnam Of Computer Science. If you manage to read over the Vietnam history, Ted makes some interesting point on the problems of O/R Mapping. I tend to agree with most of them; in fact, I mentioned most of them as well (though maybe not as eloquently). It is also interesting in the light that I spent about two hours yesterday debating some of these issues in a meeting with several other architects.
Toward the end of the article Ted offers the following solutions:
- Abandonment.
- Wholehearted acceptance. (move to an OODBMS)
- Manual mapping. (write code by hand - iBATis would fall here as well)
- Acceptance of O/R-M limitations. get the X% (50%,80% whatever) you can get out of O/R mapping
- Integration of relational concepts into the languages. (e.g. LinQ)
- Integration of relational concepts into frameworks. (embedded data-rows/data sets etc in classes to hold data, use typed data sets as well)
Ted recommends going with solution #1 or in his words "...Worse, it is a quagmire that is simply too attractive to pass up, a Siren song that continues to draw development teams from all sizes of corporations (including those at Microsoft, IBM, Oracle, and Sun, to name a few) against the rocks, with spectacular results. Lash yourself to the mast if you wish to hear the song, but let the sailors row."
The way I see it "Computer Science" now has more than 10 years of experience with O/R mapping technologies and the limitations of O/R mapping are well noted. In fact, the good O/R mappers "Accept O/R limitations" (#4 above) and provide mechanisms to by go directly at the data or provide hints for the database etc. And as I said in Part III there are situations where O/R mapping is not the best fit (e.g. reporting), but as someone at the meeting yesterday said, if you have serious reporting needs you would probably have a separate database (e.g. Datamart) just for that.
I think Ted is too quick to forgo the savings of O/R mapping (those X percentile of code you don't need to write, the fact that you externalize the data model from your code etc.) and the fact that for many problems (yes, these are "just" the simple ones, but how many times all of y our application is complicated) O/R mapping will be sufficiently good out of the box--which is,by the way, exactly why tools like Rails are getting so popular. We don't need or want to write this rote code over and over again.
I still think that if you don't expect O/R mapping to be a silver bullet which will absolve you of all your database pains--O/R mapping provides you with a good balance between benefits and costs.
Posted by Arnon Rotem-Gal-Oz at 12:12 AM Permalink | Comments