LiveBindings, which were introduced in Delphi XE2, provide developers with new options for associating objects. And they are only one of a wealth of new features introduced in this groundbreaking version of Delphi. They are also a source of some confusion. One of the problems is that most of the demonstrations of LiveBindings are simple, in part because LiveBindings are so new. Another way to put this is that it’s hard to think differently about object binding when we are so familiar with Delphi’s existing mechanisms. As a result, most examples that I’ve seen so far duplicate much of what we already achieve in Delphi.But this is bound to change. I believe that once we start to see creative applications of LiveBindings, we, the collective Delphi community, will begin to think about them differently. I hope to jump start this process by collecting examples of LiveBindings that represent the way that we’ll be using them in the future, and I’ll publish these here. Of course, I’ll give credit if you contribute so that you can bask in the gratitude of your fellow Delphi developers.So, here is my question. Do you have examples of LiveBindings that go beyond the obvious? Alternatively, have you seen an example that breaks the mold? Is so, please share. And, in case you haven’t given much thought to LiveBindings, here is a short introduction.LiveBindingsLiveBindings is a general term for Delphi’s new object/property binding mechanism first introduced in RAD Studio XE2. It is the only binding mechanism available to the new FireMonkey cross-platform component library (FMX), and is also available for traditional visual component library (VCL) components.At its core, LiveBindings is a mechanism for creating associations between objects and expressions. Expressions are strings that are evaluated by Delphi’s new expression engine, and in the case of LiveBindings, they define what effect the expression will have on an object.While expressions are strings, they are evaluated by the expression engine at runtime, which is quite a bit different than your Delphi code, which is compiled by Delphi’s compiler at compile time. As a result, expressions are different from other string types you normally encounter in Delphi code. For one thing, expression strings can define literal values using either single quotes or double quotes. In addition, the expression engine recognizes special methods that have been registered with it through Delphi’s Open Tools API (OTA), and can employ custom output converters to transform data from one type to another. Another concept critical to LiveBindings is scope. In LiveBindings terminology, scope defines what is visible to the expression engine. Most LiveBindings require a control component (the object to which the expression will be applied), and in most cases a source component as well. In the case of these LiveBindings components, the control and source components are both in scope, making their properties available to the expression engine. Similarly, those custom methods that have been registered with Delphi from a design time package are also in scope, making those methods callable from your expressions.It’s worth noting that while LiveBindings use expressions, expressions can be used without LiveBindings. Specifically, you can create a scope programmatically, adding to it the objects and methods you want the expression engine to evaluate, and then ask the expression engine to perform the evaluation, returning a value based on the expression string. It’s an important point, as far as the expression engine is concerned, but not something that you necessarily need to think about when you are using the LiveBindings components.Do We Need LiveBindings?I recently spoke about LiveBindings during the “24 Hours of Delphi” broadcast with David Intersimone. One of the listeners asked a question about LiveBindings that I hear pretty often, though he gave a somewhat new twist. “Why do we need LiveBindings?” he asked. “After all, it appears that LiveBindings is just another way of doing what we already do using event handlers. It kind of seems like fishing poles. In older days we had cane fishing poles, and they worked just fine. The new fiberglass and graphite rods are nice, but they don’t really do more than the old rods.”I like the analogy a lot, because it actually highlights why LiveBindings are a positive thing. Let’s take the fishing pole example. A recent television show on The History Channel called “101 Gadgets that Have Changed the World,” the publishers of the magazine Popular Mechanics list the top 101 devices that have had a dramatic impact on our daily lives. And, guess what, fiberglass fishing poles made the list (at 100), beating out duct tape and being edged out by the stapler.In any case, the point is that while cane poles and fiberglass fishing rods perform the same task, they work differently, and fiberglass rods are functionally better on every level.I think we are going to be saying the same thing about LiveBindings, once we get our heads around them. Yes, you can do many things with LiveBindings that can be achieved without them, but as we get more familiar with their capabilities, I believe we will discover a whole range of features that are enabled only through LiveBindings.So, let me hear from you. Post a link to your example, or an example that you find on the Web, as a comment to this posting.
Embarcadero: Firemonkey OOP
Embarcadero: Firemonkey C++