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.

Größenverhältnisse Wasserhahn-zu-Waschbecken

Seit Ewigkeiten wundere ich mich über folgendes Phänomen bei BadezimmerWaschbecken mit Wasserhahn:

Das Waschbecken selbst ist meist so breit und tief, daß darin mühelos ein Baby Platz drin findet. Somit könnte auch die Aufgabe, nämlich primär das Waschen der Hände, gut erfüllt werden.

Jedoch – der Wasserhahn selbst ist fast immer so nahe am hinteren Ausguss montiert, dass ein Hände(ab-)waschen unter fließendem Wasser nur mit ständigem Anstoßen am hinteren Ende des Beckens möglich ist. Selbst bei voll aufgedrehtem Wasser trifft der Strahl meist nicht genug in die Mitte um sich einfach die Hände zu säubern.

Nun ist meine Frage:

Warum ist der Wasserhahn so weit hinten und nicht weiter zum Benutzer hin montiert?

Folgende Gründe fallen mir ein:

  • Die Planer haben primär ein anderes Ziel als das des Händewaschens verfolgt.
  • Es sollen wirklich Babys oder Wäsche im Becken ohne störenden Hahn gewaschen werden können.
  • Es ist ein Planungsfehler.
  • Es ist ästhetischer.

In meiner vorherigen Wohnung habe ich einige Jahre lang tatsächlich mal einen (weit herausragenden) Küchenwasserhahn montiert gehabt. Es war eine wahre Freude, mir damit die Finger zu waschen!


Prinzipskizze (von oben). Links zu nahe am Rand, rechts OK.

Falls Ihr also a) meinen gewohnt ungewohnten Gedanken überhaupt folgen könnt und b) eine Antwort wisst, so lasst es mich bitte in Form von zahlreichen Kommentaren hier wissen. Danke!