Data binding – Good or evil?

For years and years I’m trying to convince myself to like and love „Data binding„.

The term „Data binding“ (or „UI data binding„) in software development refers to a technique that binds two data/information sources together and maintains them in sync, usually UI controls and underlying (database) objects.

While the theory outlines many benefits like automatic storing/loading of form content and automatic data validation, my own experiences (primarily with Windows Forms in .NET) always lead me to complicated, unreadable code that took much longer and was much harder to debug than manual setting/reading of control values.

I even developed an clean and simple test application where I tried to use databinding in an insolated environment. I was not convinced either.

For a new project I am planning to try again to go with data binding.

After doing some Google search, I decided to sum up negative/critical articles about data binding in this article, since there are many positive postings about data binding (which seem to be mostly done by marketing guys of software companies).

So here are some postings:

Databinding is EVIL

Blog posting dated 2006 by a professional software developer who worked several times with data binding in the past and now decided to not use it anymore.

Quotes:

„Ok, I am officially done with databinding….“

„…Databinding works fine if you have very simple UI that does nothing but display data in a primitive way. Soon as you introduce complex and rich UI, databinding makes things much harder. If databinding is so easy to use, why is Brian Noyes‘ book „Data Binding with Windows Forms 2.0″ 696 pages?…“

„…Maybe I am old fashioned, but manually populating the controls will be much easier and more understandable. On top of that, the code will be more testable. Less magic is a good thing…“

This guy really speaks out what I feel 🙂

Is data binding a bad idea?

Posting on Stack Overflow about the pros and cons of data binding.

Quotes:

„…Also I would like to point out the databinding shouldn’t be taken as an all or nothing approch. Many times I use databinding when i have a simple and easy UI requirment to map to my object model. However, when there is special functionality needed I might put some code in the presenter to build up the view as I need it rather than using databinding…“

Benefits of DataBinding over Manually Querying / Adding to Control

Another discussion about data binding on Stack Overflow.

Quotes:

„…It can be useful to manually bind if you’ve got a complex input scenario. With databound input controls you can find that you only know you’ve got bad data when it hits the DB and throws an exception (badly formatted date/time, integer out of correct range etc). You can obviously handle this with the various validation / pre-commit events on the data controls but it can be easier (and more obviously readable) to just manually validate your input and post it when you know it’s correct…“

UI Databinding: alternatives and future

Yet another discussion on Stack Overflow.

Quotes:

„…The WPF binding although good is too complex, it combines features of XPath with normal .Net binding and is super flexible, but very difficult to debug when it gets complex, and also very longwinded – how many IValueConverter’s does one piece of code need?…“

Other resources

  • „Why Data Binding and the like are evil“ – Old VB6 article about data binding.
  • Why Databinding Sucks“ – Blog posting about data binding.

Of cource you’ll find many more resources on Google by querying for the appropriate search terms.

As a summary for my blog posting, I would love to get tons of comments about why I am right or, of course, why I am wrong.

4 Gedanken zu „Data binding – Good or evil?

  1. Achim sagt:

    Klasse Uwe, das bestätigt meine Ablehnung gegenüber Databinding.
    Als ob es so viel Aufwand wäre das Databinding selbst zu übernehmen.
    Wenn man triviales selbst coden kann und irgendeine 3rd Party Technik nutzt dann zeugt das für mich von Faulheit – welche sich von Zeit zu Zeit grausam rächt.

  2. Achim sagt:

    Da sind wir einer subjektiven Meinung 🙂
    Ich habe schon ne Menge Leute kennengelernt die auf DataBinding schwören, deren GUI hatte aber auch die Komplexität einer 4-Textboxen-1-Button-Anwendung.

  3. Greg H sagt:

    Thanks, late to the party, but I’ve been fighting with data binding in C# this morning and I came looking for validation that I could move on from them. In C#, I’m finding data bindings frustrating to implement and without standard practices. In the past, with Obj-C (which I also found to be easier), I’ve tried data bindings a couple times but then had to roll it all back because it locked me out of some needed functionality. Harder to debug, harder to track, and it moves what would be compile time errors to runtime errors. Thanks! -G

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.