DataSets Vs. User Defined Objects
August 1st, 2008 | Published in Microsoft
In the ongoing battle between Microsoft’s DataSets and those who prefer to avoid strongly typed DataSets like the plague, I have given way to the developer inside me who wants to reinvent the wheel.
I have finished what should have been a small data input project for a small database. Along the way I used absolutely 0 typed datasets. I segmented my application into presentation, business and data layer – just like a good java programmer.
I then proceeded to write into my data access layer calls to stored procedures to get data into datasets and then immediately translated that data into generic lists of strongly typed user objects.
So now I can proudly say I have avoided strongly typed datasets altogether. But I’m in Windows Forms, and the support for object databinding is TERRIBLE. So I can’t do object databinding.
Now what?
Now I bind each control in the code behind manually. Hmmm.. the lines of code are beginning to add up here.
Now I need to know if I try and insert a duplicate object in the database or violate some other constraint. I need to now trap SQL errors along with standard exceptions and report on those accordingly.
Hmm.. more code.
So now I have finished my project and I need to make a change to one of my stored procedures and add a field. I have to change it..
1. In the procedure
2. In the translator
3. In the properties of the UDO
4. In the methods of the UDO
5. In the code of the DAL
NOT GOOD. Way too much code. I’m just not that into it. I’m not that into it and i’m OVER doing it the “right” way.
What did I learn here? Did I learn that typed datasets are superior? No. Did I learn that user defined objects are superior? No.
I learned that starting from scratch to build your own application framework is not good if you aren’t in it for the long haul.
I suppose on my next project I will use strongly typed datasets. It’s always what I have used in the past, and although they can be frustrating sometimes – in the end – they save a TON of time. Not just during development, but during maintenance too.