Monday, August 29, 2005
« .NET Rocks! interview | Main | Want to help with Katrina efforts by pro... »

I just got back from a week’s vacation/holiday in Great Britain and I feel very refreshed.

 

And that’s good, given that just before going to the UK I wrapped up the first draft of Chapter 1 in the new book Billy Hollis and I are writing. As you have probably gathered by now, this book uses DataSet objects rather than my preferred use of business objects.

 

I wanted to write a book using the DataSet because I put a lot of time and energy into lobbying Microsoft to make certain enhancements to the way the objects work and how Visual Studio works with them. Specifically I wanted a way to use DataSet objects as a business layer – both in 2-tier and n-tier scenarios.

 

Also, I wanted to write a book using Windows Forms rather than the web. This reflects my bias of course, but also reflects the reality that intelligent/smart client development is making a serious comeback as businesses realize that deployment is no longer the issue it was with COM and that development of a business application in Windows Forms is a lot less expensive than with the web.

 

The book is geared toward professional developers, so we assume the reader has a clue. The expectation is that if you are a professional business developer (a Mort) that uses VB6, Java, VB.NET, C# or whatever – that you’ll be able to jump in and be productive without us explaining the trivial stuff.

 

So Chapter 1 jumps in and creates the sample app to be used throughout the book. The chapter leverages all the features Microsoft has built into the new DataSet and its Windows Forms integration – thus showing the good, the bad and the ugly all at once.

 

Using partial classes you really can embed most of your validation and other logic into the DataTable objects. When data is changed at a column or row level you can act on that changed data. As you validate the data you can provide text indicating why a value is invalid.

 

The bad part at the moment is that there are bugs that prevent your error text from properly flowing back to the UI (through the ErrorProvider control or DataGridView) in all cases. In talking to the product team I believe that my issues with the ErrorProvider will be resolved, but that some of my DataGridView issues won’t be fixed (the problems may be a “feature” rather than a bug…). Fortunately I was able to figure out a (somewhat ugly) workaround to make the DataGridView actually work like it should.

 

The end result is that Chapter 1 shows how you can create a DataSet from a database, then write your business logic in each DataTable. Then you can create a basic Windows Forms UI with virtually no code. It is really impressive!!

 

But then there’s another issue. Each DataTable comes with a strongly-typed TableAdapter. The TableAdapter is a very nice object that handles all the I/O for the DataTable – understanding how to get the data, fill the DataTable and then update the DataTable into the database. Better still, it includes atomic methods to insert, update and delete rows of data directly – without the need for a DataTable at all. Very cool!

 

Unfortunately there are no hooks in the TableAdapter by which you can apply business logic when the Insert/Update/Delete methods are called. The end result is that any validation or other business logic is pushed into the UI. That’s terrible!! And yet that’s the way my Chapter 1 works at the moment…

 

This functionality obviously isn’t going to change in .NET or Visual Studio at this stage of the game, meaning that the TableAdapter is pretty useless as-is.

 

(to make it worse, the TableAdapter code is in the same physical file as the DataTable code, which makes n-tier implementations seriously hard)

 

Being a framework kind of guy, my answer to these issues is a framework. Basically, the DataTable is OK, but the TableAdapter needs to be hidden behind a more workable layer of code. What I’m working through at the moment is how much of that code is a framework and how much is created via code-generation (or by hand – ugh).

 

But what’s really frustrating is that Microsoft could have solved the entire issue by simply declaring and raising three events from their TableAdapter code so it was possible to apply business logic during the insert/update/delete operations… Grumble…

 

The major bright point out of all this is that I know business objects solve all these issues in a superior manner. Digging into the DataSet world merely broadens my understanding of how business objects make life better.

 

Though to be fair, the flip side is that creating simple forms to edit basic data in a grid is almost infinitely easier with a DataTable than with an object. Microsoft really nailed the trivial case with the new features - and that has its own value. While frustrating when trying to build interesting forms, the DataTable functionality does mean you can whip out the boring maintenance screens with just a few minutes work each.

 

Objects on the other hand, make it comparatively easy to build interesting forms, but require more work than I'd like for building the boring maintenance screens...

Monday, August 29, 2005 4:08:32 PM (Central Standard Time, UTC-06:00)
Rocky, I am so thrilled that you are giving this topic due attention. When is the anticipated release?

Regards TableAdapter, I don't see why we (or someone) shouldn't write an extension to the current xsd.exe that not only allows you to use more sophisticated Insert/Update/Delete logic, but also plug your own business logic into it. Sounds like a perfect fit for the provider model eh? This also begs the question why strongly typed datasets didn't already have these extensibility hooks.

One additional suggestion I have is to illustrate the extensibility of the new dataset and provide features such as multiple level undo's etc.

I believe datasets have been criticized nilly willy and such a book should simply zip all those criticisms. I'm not sayin g they usurp business objects, but they do have a place in system architecture.

Looking forward to your book.
Tuesday, August 30, 2005 7:10:23 AM (Central Standard Time, UTC-06:00)
Is there concern given the visibly poor performance characteristics that the DataSet exhibits when passed over the wire in various scenarios such as remoting, web services, or ES?

The numbers provided here were pretty poor I thought:

http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnwebsrv/html/asmxremotesperf.asp

IMHO, providing a more relational view of your domain might make sense in terms of marshaling data across tiers and machine boundaries, but seems to lack a lot of expressiveness on the backend. Will be interesting to see how this evolves over the next few releases. Thanks and good luck with the new book effort!
kris
Thursday, September 01, 2005 6:36:17 AM (Central Standard Time, UTC-06:00)
ADO Guy (http://adoguy.com/content.aspx?id=book/datasetgenerator) has done a lot of with typed datasets centred around improving the existing typed dataset to make it more easily inheritable and thus easier to incorporate business logic. He has a lot of interesting thoughts on the subject.
Ian
Tuesday, September 06, 2005 1:14:55 PM (Central Standard Time, UTC-06:00)
Yes, I known Shawn (the ADO Guy) and have a great deal of respect for him and the work he's done in this area. Microsoft is changing typed datasets rather a lot in VS 2005 however, so the strengths and limitations are different. I am sure Shawn will have solutions for many of the new limitations and I look forward to seeing what he produces.
Comments are closed.