Latest Tweet:
  • Loading...

ORMNam Back in June 2006 Ted Neward wrote an excellent article about ORM titled "The Vietnam of Computer Science". Two years later we conclude that we’re still stuck in Nam, and it’s only getting hotter…

nHibernate is now maturing and a beta of their second major release (2.0) was just released. After the failures of Object Spaces and WinFS it looks like Microsoft is stepping up their data programmability efforts with two ORM offerings, LINQ to SQL (part of .NET 3.5) and ADO.NET Entity Framework (releasing in .NET 3.5 SP1). Some developers are fearing (or hoping?) that LINQ to SQL might be the next casualty of war, as there really hasn’t been a lot of improvements or announcements made around LINQ to SQL after its initial release, as expressed in the post "Is the ADO.NET team abandoning LINQ to SQL".

Things got really hot for the ADO.NET Entity Framework team last week, as a "vote of no confidence" was put out. So far it’s signed by 392 developers. Tim Malalieu, program manager on the EF team, responded with a detailed post addressing the concerns rose in the "vote of no confidence", and it’s good to see Microsoft responding to the concerns of the developer community. Microsoft has also put together a council including Eric Evans, Martin Fowler, Paul Hruby, Jimmy Nilsson, and fellow Regional Director Stephen Forte.

Stephen did a great post on his take on the whole ORM debate this weekend, and I figured commenting on it would be a good way of getting "back into blogging" after being quiet for almost three weeks. I mostly agree with what Stephen is saying, and one of the points he makes is about embracing the impedance mismatch rather than trying to ignore it:

So ORMs are trying to solve the issue of data access in a way that C# and VB developers can understand: objects, procedural, etc.  That is why they are doomed to fail. The further you abstract the developer from thinking in a set-based way and have them write in a procedural way and have the computer (ORM) convert it to a set-based way, the worse we will be off over time.

What I am saying (and have been saying for a long time) is that we should accept, no, embrace the impedance mismatch!  While others are saying we should eradicate it, I say embrace it.

One of the things I love about C# 3.0 and LINQ (not LINQ to SQL) is how it gives you a nice way to work in memory data in procedural code. I’ve seen heaps of examples of bad code with several levels of nested for-each loops “mimicking” set based operations. In many cases these big chunks of codes can be simplified to one simple easy to read LINQ expression. But, then again perhaps the problem could have been solved in the database in the first place..?

The ironic thing I’m now seeing is developers who are lazy and don't want to learn SQL using tools that will produce SQL for them. The SQL is bad, and now those same anti-SQL lazy developers are struggling to read pages of generated and near-unreadable SQL trying to solve performance problems. They’re dealing with SQL that’s more verbose and orders of magnitude harder to understand than what was needed in the first place!

This brings me nicely to the reason for my lack of blogging the last three weeks. I’ve been too busy doing database integration and reporting work for a medium sized organization here in Melbourne. The problem I was faced with was establishing a platform for data integration between line-of-business applications to do management reporting. The organization had a basic reporting solution today consisting of a set of VB- and Python scripts being executed by scheduled tasks to pull the data into a report database. The actual reports where generated by an ASP.NET 1.0 application that populates data grids. As you can imagine this is no ideal solution, and is both hard to maintain and extend, and really doesn’t solve the business need of the customer. When the exciting solution didn’t give the reports they needed they had to do manual Excel reports.

The developer in me who loves shiny new framework might see this as an opportunity to migrate the exciting solution to something sassier, say ASP.NET MVC + ADO.NET EF, and perhaps a dash of Silverlight to show some great KPI's. Thankfully I keep “cool” and did the reasonable thing (the "right tool for the job"-cliché): SQL Server Integration Services and SQL Server Reporting Services. I solved the problem by building the SSIS packages based on the exciting scripts, and complimented them with additional imports where needed to meet new requirements. During the report authoring (something I did together with one of their business people who knew what reports they need) I discovered how “rusty” my SQL skills had become. It took a couple of days to "loosen up" and be completely up to speed with writing joins, groupings, aggregators and more to get the reports they wanted. I think this is the case for more and more developers these days.

The database engines are becoming more and more powerful, yet I suspect the average developer to take less and less advantage of this power. By writing "dumb plumbing" code to populate .NET objects we forget the power of the database, and think everything now can be solved by putting a ORM on-top of the database.

That being said I do think the ORM has its place in application architecture, but as any tool you need to learn how to use it right, and know what problem it can solve. Personally I love using ORM for my simple CRUD operations, and whenever needing you can always drop down to hand written SQL. I remember when I did my first ORM project on an early version of LLBLGen back on .NET 1.1. We didn’t have partial classes, so any modification made to the auto generated code had to be written between special region comments that didn’t get overwritten when doing a regeneration of the code… We’ve come a long way since then.

And for the project I’ve been working on: We delivered today, on time and above expectations. The customer already had SQL Server installed (and SSIS and Reporting Services, perhaps without knowing), so deployment was a breeze. The new solution is easier to maintain and extend by the customers IT organization, and offers a unified way to do reporting and data integration. And as for sexy Silverlight 2 KPI gauges we didn’t get time to do it this time. By using Reporting Services to export to XML I’m sure we could do something cool within this framework. Well that’s a whole different blog post...

Tuesday, July 01, 2008 3:25:19 PM (W. Europe Daylight Time, UTC+02:00)
Wow! 392 Developers!?!

So after a week and a whole lot of hype they have almost 1/100 of a percent of .Net developers signed on? Incredible! The ADO.Net team is really on the hot seat now.
Wow
Tuesday, July 01, 2008 4:20:41 PM (W. Europe Daylight Time, UTC+02:00)
I've tried to stay out of the EF debate, but yet again I can't keep my mouth shut :-)

IMHO, not being tempted to use EF for your reporting needs was a wise choice. This is actually right at the core of the seasoned .NET developers vs. the Entity Framework debate. One thing that makes EF fail is that it looks to be all things to all men. Quoting from the EF vision document:

"Long-term we are working to build EDM awareness into a variety of other Microsoft products so that if you have an Entity Data Model, you should be able to automatically create REST-oriented web services over that model (ADO.Net Data Services aka Astoria), write reports against that model (Reporting Services), synchronize data between a server and an offline client store where the data is moved atomically as entities even if those entities draw from multiple database tables on the server, create workflows from entity-aware building blocks, etc. etc."

The problem here is that these things are very different from one another. You'd use entities when your building a business application, because here you are first and foremost concerned with the behavior of the entities, not the data it self. And to comment on your quote from Stephen; your seldom dealing with set-based data in such scenarios.
Whenever you're just reporting off the database, showing data grid that isn't updated, introducing an entire domain/entity model just brings a lot of unneeded complexity. Reports basically just roll up data and SQL is the better choice for doing this. Reporting is generally set-based.
However, business rules are very hard to express in T-SQL and hence you should keep this in your domain model to keep the design maintainable. The problem with EF here is that it is too intrusive and it doesn't support a domain model centric architecture well.

You're right that many devs suck at SQL - I do too. From my experience this isn't a problem when relying on tools like NHibernate to do database integration, because those tools "write" much better SQL code than I would do myself.
Wednesday, July 02, 2008 12:56:40 PM (W. Europe Daylight Time, UTC+02:00)
Anders: Thanks for a great comment - As allways well tought through and some good points. Didn't know Microsoft where aiming _that_ broad with their EF efforts. A technology that tries to be everything for everyone is seldom a good idea.

Also good point that the tools might write better code than what you would write your self by hand.

Wow: Well, this is not like those "if 10 000 people join I'll walk to china" Facebook groups. Lots of the signees are MVP's and active community members that Microsoft listen to... And the responses made by the EF team, as well as discussion on different mailing list, indicates that Microsoft really take these concerns serious.

Friday, July 18, 2008 9:56:31 AM (W. Europe Daylight Time, UTC+02:00)
Do you remember how you learned SSIS? It seems a bit difficult to grasp for beginners. Quite a different way of thinking, compared to writing .NET applications to solve the same problems. SSIS offers a much greater potential for reuse though, being heavily component oriented. I think much of the clue lies in understanding how the default components can be used to solve various tasks.
Eivind Gussiås Løkseth
Saturday, July 19, 2008 12:38:15 PM (W. Europe Daylight Time, UTC+02:00)
Hi Eivind,

Agree that it takes some time to get your head around SSIS. The data flow way of thinking is a different from traditional OO coding in .NET.

I picked up SSIS by reading online docs and articles and just playing with it, and I'm by no means an expert. For the project I mentioned I probably didn't use more than 8-10 different tasks for the integration packages.

But I think more devs should be avare of SSIS and what it can do, as it's way better suited to do data driven integration than for instance procedural code.
Wednesday, May 20, 2009 4:21:58 PM (W. Europe Daylight Time, UTC+02:00)
Hi guys. You don't get anything clean without getting something else dirty. Help me! I find sites on the topic: meth addiction. I found only this - <a href="http://design.ru-deluxe.ru/">adobe photoshop cs2 na russkom</a>. Learn about the steps to alcohol recovery, including how to safely stop drinking different types of alcohol treatment and support, what to look for in. An intervention program for alcohol treatment in indiana. Waiting for a reply :cool:, Onida from Maldives.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
<August 2010>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234