Here's an interesting discussion on DataSets vs. Custom Classes/Collections.
It is interesting because I can look back over the last few years when I started
blogging and see how my opinion on the subject as evolved, and it is kinda
comical. But hey, .NET developers are are all new to .NET development in a sense
simply because .NET hasn't been around very long! So, I expect most people to
look for better ways to do things. Here's how my thoughts have evolved...
- .NET arrives on the scene and I use the DataReader almost exclusively.
- At some point I move to the DataSet almost exclusively after getting
burned by not closing/disposing DataReaders.
- At some point I discovered Duwamish books installed with Visual Studio
.NET 2002, and I decide that typed-DataSets are pretty cool.
-
August 2004 I liked typed-DataSets more than sliced bread and
more of the same.
-
August 2004 I'm still trying to decide if I like the idea of using custom
collections or not after having fallen in love with typed-DataSets.
-
October 2004 I'm researching O/R Mappers and am skeptical. Plus, there
are
more reasons to be skeptical.
-
October 2004 I read Fowler's book and decide it is OK to like the Table
Module approach using typed-DataSets in .NET.
-
January 2005 I'm still not sold on O/R Mappers but I'm giving them a
fair shot.
-
March 2005 I'm starting to like an O/R Mapper product (LLBLGen
Pro).
-
Late March 2005 I'm starting to like an ORM even more despite the bad
press.
- August 2005 (today), I've been using LLBLGen Pro for 6 months now and it
is very slick! I prefer the class/collection approach instead of typed-DataSets.
Now, all of that being said, what have I learned from this experience? A lot
I hope. :-) I chuckle at my varying opinions, but at the same time I
have to credit being open-minded (despite the sarcasm in some of my blog posts)
for my change in design approaches. Unless you TRY things, you will never know
what alternatives you have. I tried using DataSets...I tried using typed-DataSets...I
tried using custom collections...I tried using an ORM product. It is always
worth it to keep an open mind and try things. I've posted this statement many
times and I'll do it yet again, "I'm always looking for better ways to do
things." That's the best approach IMO, not making blanket statements such as "DataSets
suck" or "Custom collections are too complex." The approach you take depends on
the problem you are trying to solve. A linear search might be OK in some cases,
whereas in other cases a binary search makes more sense. It's like arguing over
using a Hashtable versus an ArrayList - use what is appropriate. So, I prefer
custom classes/collections for my object models, but that doesn't mean DataSets
wouldn't work either. I will say that I'm still firm on my stance that typed-DataSets
are infinitely better than System.Data.DataSet to code against.
Anyway, now I'm taking a good look at the
Enterprise Library to see how well it might work out for me on future
projects. I already have used the Exception Management Blocks and Data Access
Blocks, so it should be fairly straight forward. What do you think? Have you
evolved in your design approaches since the .NET Framework was first released?
Drop me a line and share your story.