OR Mapping vs DAL

This is an open forum for any mojoPortal topics that don't fall into the other categories.

This thread is closed to new posts. You must sign in to post in the forums.
4/12/2005 5:12:47 PM
Gravatar
Total Posts 2

Re: OR Mapping vs DAL

I don't care to convince you one way or another.  My only interest in this topic is in learning, as I'm contemplating creating my own CMS from scratch.

There's a few things you've claimed that I don't understand.  First, you claim there's things you can't do with OR Mappers because they only support CRUD.  What else would you realistically want to do?  I know you mention the forums paging and sorting.  The paging I can almost see, because this is highly DB specific.  However, I wouldn't be surprised if some OR Mapper can handle this.  And even if not, you can implement the paging through cached data instead of always hitting the DB.  As for the sorting... most OR Mappers include a query language (like Hibernate's HQL) that's usually as powerful as SQL.  You mention using a temp table... but I generally find that to be a poor solution in all but the most extreme cases.  So, what am I missing here?

I'm not sure I agree with your point about code generation either.  The generated code is still long and not necessarily easy to understand.  It's certainly not easier to maintain.  Find a bug and you'll have to fix it in every piece of already generated code.  The OR Mapper on the other hand is an abstraction.  It simplifies the code which helps not only at the time of creation, but also during maintenance.

The point about being optimized *may* be true... but that's likely premature optimization.  Applications I've used that were implemented with OR Mappers perform just fine.

The point about complexity is both true and false at the same time ;).  Certainly OR Mappers are at least as complex as SQL, and so if you know SQL but don't know the OR Mapper there's a lot to learn.  However, there's also the complexity of the DAL and the ADO.Net to consider.  For most things I think the code for the OR Mappers is less complex than the code for ADO.Net.

Your target audience's skill set is absolutely a valid concern.  The only one I don't find any fault in, actually. ;)

I'm not trying to say you're wrong.  That would be the height of arrogance.  But since my experience with OR Mappers is not very extensive yet, I'm wondering how valid your remarks are in light of these "devils advocate" points of view.  NHibernate in particular seems to be a fairly simple yet powerful OR Mapper that would be well suited to this type of project.
4/13/2005 2:49:16 AM
Gravatar
Total Posts 18439

Re: OR Mapping vs DAL

I hold to my position and have no need to convince anyone or defend it or debate it further. I choose not to use OR mapping in this project but certainly can see why some would rather use it.

I feel that I have expressed the reasons for my decisions on this topic both here in this thread and on the Architecture page http://www.mojoportal.com/Default.aspx?pageindex=5&pageid=4
While I have good friends who probably think I should choose OR mapping and I respect their opinions a great deal, I choose not to and hope my position can also be respected and understood as a reasoned decision.

There are passionate opinions on both sides of the debate, if you are interested in reading about it there is at least one interesting thread here

http://www.theserverside.net/news/thread.tss?thread_id=29071

I have no further energy to debate it as I would rather put my energy into development. Let people think what they may I have no plans to use any OR mapper in mojoportal. If anyone finds that to be a reason not to use mojoportal that is not my concern.

I will say that I don't find the DAL code to be very complex. I use the SqlHelper from the  MS Application blocks to abstract a lot of the complexity of ADO.NET so the code in my DALs is very easy to understand at least for me. There is a corresponding MySqlHelper and Joseph Hill also put together a npgSqlHelper for PostgreSQL.

11/11/2005 4:50:18 PM
Gravatar
Total Posts 148

Re: OR Mapping vs DAL


FYI, here's an updated link for the blog "discussing performance in OR mapping or at least the MS implementation".

--Dean
5/29/2006 10:28:51 AM
Gravatar
Total Posts 18439

Re: OR Mapping vs DAL

I would like to add to this thread that recently I have had an opportunity to use an OR Mapper at work, specifically Wilson OR mapper. I definitely see the benefits in terms of rapid development but in addition to the other points I have made here about why I don't think I should use an OR mapper in mojoPortal I would like to add another reason.

OR Mappers and code generation tend to lead to a one to one correspondence between classes and db tables. In the book Object Thinking, the author makes an argument that I agree with that this approach is data driven development and not true OOP. In tru OOP you want to think about the natural joints in your object hierarchy. While it is true that you often naturally have a correspondence between tables and classes this is not always the way your object hierarchy should be and you end up with what the author describes as an explosion of classes.

I use code generation to stub out standard db crud code but I don't do it in a way where you can re-gen if you add a column because I don't always have a class for every table but I still get a jump start on development with this approach.

Using code generation with the re-gen approach or using OR mappers forces you into this one to one correspondence and I don't favor this approach for an art project like mojoPortal, though I could see the benefit of doing it in many projects where reduction in time to development may be a higher priority.
You must sign in to post in the forums. This thread is closed to new posts.