25.2. Data Binding

Data binding is not unique to Cairngorm. However, it is the primary mechanism for updating views using the ModelLocator. Putting a lot of bindable data in a single class can create performance problems for your application. So while these criticisms are equally valid for data binding in general, they do have particular relevance to Cairngorm.

Data binding is a nice convenience feature. It is relatively simple for the programmer writing the code to tie properties on a view to a variable with data binding — then, magically, the views change whenever the data does. In many languages the developers themselves have to write the code to update the view.

As with many of the nice features of many programming languages, "nice" does not come without a cost. While you, the developer, no longer have to write the code to update the views, this is only because Flex does it for you. A lot of code gets generated behind the scenes to make data binding work.

If you are unfamiliar with what actually goes on when you use data binding, a description can be found in the Adobe Live Docs at http://livedocs.adobe.com/flex/3/html/databinding_2.html#162751, which reads as follows:

Binding occurs under the following circumstances:

  1. The binding source dispatches an event because the source has been modified. This event can occur at any time during application execution. The event triggers Flex to copy the value of the source property to the destination property.

  2. At application startup the ...

Get Professional Cairngorm™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.