Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Any books about building "Real" .NET Winforms Apps

My lead engineer must buy three .NET books a week. All of them seem to have the same flavor. "Let's build this one-form app that loads the data, then shuts down!"

We're trying to reengineer our application that was originally built in Microsoft Access.  What we're finding is that there are not any books out there about building a good ole' fashioned client/server database application using .NET.  What's especially frustrating to us is figuring out just how you're supposed to work with and manipulate data.

Here's an example. You load up a dataset with about 200 records. You bind some controls and combo boxes and datagrids to the dataset.  Now, you want to do some data manipulation.  Let's say, you want to reload the data, apply a custom calculation to the rows, look up some related data and stuff those into columns that exist in the dataset but not in the database, and display the resultant set on the form.

Well, we come to find out, as we're working with the data, .NET is pumping about 18,000 events to the controls on the form as each column changes and row changes, slowing performance to a halt! (The really bad one seems to be the ListChanged event that gets fired as we're loading our updated data in.)

It seems like the correct way to use this stuff is to somehow build a completely new set of data while it's not connected to a form, then somehow "swap it in" for the current data that's attached to the form.

Has anyone out there actually built a real multi-user client server Windows Forms application that deals with thousands of rows of data?

Dave
Saturday, April 26, 2003

To turn off events etc try using dataTable.BeginLoadData() and then dataTable.EndLoadData().

To perform computations on the data look into dataTable.Compute(expression, filter).

Another thing to consider is calculated columns. Use:
  dataTable.Columns.Add(expression);

Also try using SuspendLayout/ResumeLayout on the control/form.

Read the docs after you've read a decent book (like Stalingrad by Anthony Beevor ;-) ).

Duncan Smart
Saturday, April 26, 2003

If what you're looking for is a .Net Windows Forms books whose "example app" is a bit more "well-thought-of" than usual, I'd recommend "Windows Forms Programming with C#", by Erik Brown (Ed. Manning)

I was involved in reviewing the book prior to publishing, and one of the things I liked most was that the sample code / app was geared to "real" Windows apps, being carefull to follow apps conventions, and pointing the "proper" way when doing so would've been out of the scope of the book... All in all, I believe it's a great book.

Also, you've got a quite lively forum on the book and the topics it covers, and the author chimes in every now and then, so it's nice "support" ;)

Ok, enough for now ;)

Javier
Sunday, April 27, 2003

Before you start to use hardcore databinding read this:

http://NoiseEHC.fw.hu

It can save months of work.

NoiseEHC
Monday, April 28, 2003

Duncan:
Thanks for the suggestions. Here's some feedback:

- Unfortunately, BeginLoadData and EndLoadData does not turn off all events. For example, RowChanged events are still broadcast, even during a Fill or Merge.

- Compute() and expression columns are not rich enough to support what we need to do.  Here's a simplified example: 1. User adds a child record containing a total cost that is multiplied by one of two factors in the parent row. 2. System rolls through each child row, multiplies the total cost by the appropriate factor in the parent row, then sums the results. The result is then scaled by a factor stored in another datatable.

- SuspendLayout and ResumeLayout only affect size, location, docking, and anchoring. These methods do not affect events generated by making datatable modifications. (This was one of the first things we latched onto about 6 months ago. Useless to solve our particular problem.)

- We've been reading the documentation for a year and a half, have read a half dozen .NET books, and decompiled all of System.Windows.Forms, along with several other namespaces, and studied the code in depth. We've done our homework, but still looking for more answers!

Javier:
We have NOT checked out "Windows Forms Programming with C#" yet.  We'll check it out right away.  Thanks for the help.

NoiseEHC:
Thanks for the link!  We have read some of the articles you've linked to, but others we have not.  We'll check it out.

Dave
Monday, April 28, 2003

Dave - how about taking a copy of the DataSet using Copy() and doing the work "offline" with that, then either Merge() it back or rebind the new DataSet?

Duncan Smart
Tuesday, April 29, 2003

Duncan:

I think the approach we're leaning towards for what we've built so far is similar to what you've outlined--"disconnecting" the dataset while it's "worked on," then rebinding it. We're going to try this later on this week and next week.

Going forward with the balance of the application, where the business rules are much more object-based, I think we're going to go with an approach where we design custom business entity classes generated by a data access logic component, outlined in Microsoft's Designing Data Tier Components and Passing Data Through Tiers article. (See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndesign/html/design09102002.asp )

We're working on the architecture design document right now.  We'll let you know how it works out!

Dave
Tuesday, April 29, 2003

*  Recent Topics

*  Fog Creek Home