Monday, 18 April 2011

ORM is a Solved Problem

==========
Practices of an Agile Developer (Neill Alexander) (Hunt Subramaniam)
- Highlight Loc. 864-66  | Added on Friday, April 01, 2011, 08:47 AM

For instance, if you have a hankering to develop your own persistence layer, remember Ted Neward's remark that "object-relational mapping is the Vietnam of computer science." You can spend more time and effort building only what you need to build for your application---the domain or application-specific stuff.
==========

This made me laugh, because I built a persistence layer for a project, then realized after the fact that I should just have used Hibernate. It was a valuable lesson.

The thing is, at one point during the project I was talking to the project manager who expressed his concern at the length of time it was taking to complete the work. I said to him, "Don't worry, I'm not trying to re-implement Hibernate!". Shortly after that conversation I realized that I was, in fact, trying to re-implement Hibernate. It all started very naively - I implemented a solution using Spring JDBC, and then saw an opportunity to extract some higher level abstractions. That process continued to the point that I found myself writing a DSL that would enable me to express the various object relationships, and map them to the database structure.

Hmmm. Object relational mapping you say. That rings a bell.

Object-relational mapping is a solved problem. There are multiple solutions out there. Pick one and use that. Even if you need to learn it from scratch, it will still be quicker than writing your own version.

No comments:

Post a Comment