I was arguing in an instant message window today. I was trying to relay the awesomeness that is Castle Project’s Active Record. I realized I’m not a very good arguer. I found myself digging for URLs which I know I had read, which do the comparison of DAL vs. ORM and dispel the myths that “you must use stored procedures for all database access”.
As I was skimming reverse chronologically through Ayende’s blog, I realized that for someone starting off, reading these things in some kind of logical order would help. I’ve decided to try to put things in some kind of order. Regarding Ayende/Oren’s blog, his really is all you need. He links to many other sites with excellent information.
So first, I’d like to try to build a case for using ORM. I don’t have to do much, it has been done for me:
- Paul Wilson writes an ORM. This post describes how using one isn’t all that different from what we are used to. http://weblogs.asp.net/pwilson/archive/2006/05/27/The-Truth-about-Stored-Procs-and-O_2F00_R-Mapping.aspx
- Its not about data. It is about Objects! http://www.ayende.com/Blog/ORMIsNotAboutData.aspx
- There is Microsoft’s recommended way, and then there is the better way. http://www.ayende.com/Blog/TackingComplexityIntoTheHeartOfSoftware.aspx
- When I first started doing the NHibernate/ActiveRecord thing, I had a need that I knew exactly how to fill using SQL, so I wanted to just get a db connection and execute the SQL. This is usually the wrong approach. http://www.ayende.com/Blog/AvoidMixingORMAndSQL.aspx
- There is a PowerPoint. I must have missed this when it was posted. Looks like a nice introduction. http://www.ayende.com/Blog/IntroductionToCastle.aspx
- Stored Procedures just don’t cut it.
- Its not about security http://www.ayende.com/Blog/StoredProceduresForSecurity.aspx
- A follow up:Â Â http://www.ayende.com/Blog/StoredProceduresAsPrimitiveServices.aspx
- Clarification points are succinct. I couldn’t agree more with these. I think maybe we could come up with some more points too. http://www.ayende.com/Blog/AdvantagesOfStoredProcedures.aspx
Just because you are using ORM, doesn’t mean it is magic. http://www.ayende.com/Blog/YouCantEscapeTheComplexity.aspx You have to still understand what is going on under the hood. This is definitely an area in which I am lacking.
It is probably best to read Clemens Vasters post, then read Ayende’s follow ups. They are very enlightining. It is great to get both sides of the issue.
- http://friends.newtelligence.net/clemensv/PermaLink,guid,0fbf07a9-9e7a-4db4-a305-58250ac57a73.aspx
- http://www.ayende.com/Blog/2006/03/07/ClemensOnORMappers.aspx
- http://www.ayende.com/Blog/MoreAboutObjectRelationalMappersVsCustomDAL.aspx
- http://www.ayende.com/Blog/ClemensOnORMapeersTakeII.aspx
Don’t think DLINQ is the answer, or that it does more. Many DLINQ fans don’t realize that most ORMs have been able to do this stuff for years. http://www.ayende.com/Blog/UsingORMProperly.aspx
A comparison of LLBLGen to NHibernate. Now to be fair, Oren is a contributer to NHibernate so he may be a little biased. I’ve not used LLBLGen, but I have browsed its documentation, and I’d also rather use NHibernate. http://www.ayende.com/Blog/LearningAboutLLBLGen.aspx
On security of the stored procedure approach vs. ORM. This is a great detailed description. http://www.ayende.com/Blog/OneUponATimeInAnITOperationFarFarAway.aspx
For some reason there are LIES surrounding ORMs. Know this: They are lies. http://www.ayende.com/Blog/PissedOffByVanatecOpenAccess.aspx
Some people have responded to others and said “I’ll write my own!” Oren(Ayende) gives 25 reasons not to:
http://www.ayende.com/Blog/25ReasonsNotToWriteYourOwnObjectRelationalMapper.aspx
It turns out he was repeating himself, because he mentioned it a little less detailed months before: http://www.ayende.com/Blog/YouReallyShouldntWriteYourOwnORM.aspx
A common problem to run into once you start using an ORM, any ORM, is know as the SELECT N+1 Problem. http://www.ayende.com/Blog/CombatingTheSelectN1ProblemInNHibernate.aspx
I’ve never done this, but I should probably keep it in mind. I’ll bet I could use it, and it is a great example of how quickly you can get things done using these tools. http://www.ayende.com/Blog/UnderusedNHibernateFeatureCreatingObjectsInTheSelectClause.aspx
I haven’t even read these yet. How could I have missed them? They go into how it works.
All you wanted to know about Castle’s ActiveRecord – Part I
All you wanted to know about Castle’s ActiveRecord – Part 2
Finally, there is a whole series of posts building up a demo app, including using Brail for MVC. This is ActiveRecord + MonoRail stuff, a great way to see the big picture. http://www.ayende.com/Blog/CasleDemoAppMidwaySummary.aspx
A couple of items which I think are worth reading, but I couldn’t fit into this semi-ordered list of links.
- http://www.ayende.com/Blog/AFewWordsAboutTheDecoratorPattern.aspx
- http://www.ayende.com/Blog/AdvancedUsesForORM.aspx
- http://www.ayende.com/Blog/ComplexSearching.aspx
- http://www.codeproject.com/aspnet/NHibernateBestPractices.asp
- http://www.codeproject.com/cs/design/IntroducingCastle.asp
- http://www.codeproject.com/cs/design/introducingcastleii.asp
Once you are familiar with the ActiveRecord library, I highly recommend checking out the rest of CastleProject. Windsor is awesome. MonoRail is ASP.NET on steroids.
4 thoughts on “ORM vs. your own DAL with everything in Stored Procedures”
Comments are closed.