views:

47

answers:

2

This guide on optimizing DataBinding says:

There is a significant performance impact when you data bind to a single CLR object with thousands of properties. You can minimize this impact by dividing the single object into multiple CLR objects with fewer properties.

  1. What does this mean? I am still trying to get familiar with DataBinding, but my analogy here is that properties are like SQL table fields, and objects are rows. This advice then translates to "to avoid problems with a large number of fields, use less fields and create more rows". As this doesn't make any sense to me, possibly my understanding of databinding is completely askew?

  2. Does this advice actually apply? I am unsure if it is specific to .NET 4/WPF, while i am using 3.5 and a custom WinForms based control library (DevExpress)

  3. As an aside: am I correct in thinking DataBinding uses reflection when an using IList style datasource?

This is not just a academic question. I am currently trying to speed up loading a XtraGridView (DevExpress Control) with ~100,000 objects with 50 properties or so.

+1  A: 

This advice then translates to "to avoid problems with a large number of fields, use less fields and create more rows"

I think it should translate to "use less fields and create smaller tables" (i.e. with less fields). And the original advice should read "[...]dividing the single class into multiple classes", with fewer properties. As you correctly noted, it wouldn't make sense to create more "rows"...

Anyway, if you do have a class that exposes hundreds or thousands of properties, you have a far more serious problem than binding performance... This is a serious design flaw that you should fix after reading some OO principles.

Does this advice actually apply? I am unsure if it is specific to .NET 4/WPF, while i am using 3.5 and a custom WinForms based control library (DevExpress)

Well, the page you mentioned is about WPF, but I think the idea of binding to smaller objects can apply to WinForms too (because the more properties need to be watched, the slower it will be)

As an aside: am I correct in thinking DataBinding uses reflection when an using IList style datasource?

You're partially correct... it actually uses TypeDescriptor, which in turns uses reflection to examine regular CLR objects. But this mechanism is much more flexible than reflection: a type can implement ICustomTypeDescriptor to provide its own description, list of members, etc (DataTable is one example of such a type)

Thomas Levesque
The class exposes maybe 50 - but it exists specifically for the databinding, and is actually composed of a series of other classes which share a semantic link
fostandy
+1  A: 

You are solving the wrong problem. It will take a typical user well over a week to find back what she is looking for when she's got 5 million fields to search through. The speed of your UI becomes irrelevant. Only a machine can do a better job finding the data back.

You've got one. Help the user narrow down what she is searching for by letting her enter search terms so that the total query result doesn't contain more than, say, a hundred rows. The dbase engine helps you make that fast. And it automatically solves your grid perf problem.

Hans Passant
I'm not sure where I gave the impression that I am using theDataGridView to allow a user to search for something - I'm not. I am using it to display a whole bunch of information. Users currently look at a large excel spreadsheet with 100k rows and 50fields. I want to display the same information in my application, with certain value adds (be able to link each object/row back to other elements of my app)
fostandy