Usage for LiveBinding
Asked Answered
D

1

6

I don't understand LiveBinding's purpose. I would like to know which are the cases in which LiveBinding is most valuable. Embarcadero's manual describes it: "LiveBindings is a data-binding feature supported by both the VCL and FireMonkey frameworks in RAD Studio. LiveBindings is an expression-based framework, which means it uses binding expressions to bind objects to other objects or to dataset fields".
Thanks but I still don't know more than before.

I have seen some video in which a guy spends 12 minutes and hundredths of clicks to connect the caption of a TLabel to a TListBox control. When the user clicks an item in ListBox the name of the item is shown in Label. I could have done that with a single line of code (few keystrokes and no mouse clicks). I am not criticizing LiveBinding. I am saying that I don't understand where it is helpful. I am missing something. Since it is not doing something that cannot be done from code, it means it's doing something that can be done from code, but visually and much much faster. I admit I haven't invested a lot of time in this topic but everywhere I look I see a terribly convoluted way (come on, you really need 5 extra controls to make LiveBinding works?) to do a simple task.

Also, it seems that LiveBinding was mostly designed for DB. All examples will include some kind of DB connectivity. But I am expressly interested only about the cases where I can use LiveBindings and there is no data set/DB involved. I am not using DB that much.

Destructor answered 24/10, 2016 at 13:31 Comment(0)
P
4

I doubt v. much that anyone would use live bindings if they could use traditional db-aware VCL components. However, that's not an option for non-VCL projects (Android, Apple, etc) and live bindings is the only Emba-supplied option for delivering data to those from TDataSet descendants.

An advantage of live bindings is that in addition to the Android and Apple targets, you can use them in Windows apps, so conceivably you could write the same (FMX-based) application for all three.

Libe-binding can also be used in VCL applications, but tbh, I can't imagine why anyone would use live bindings if they were only targeting a Windows DB application, as they are much slower than the traditional db-aware controls, especially multi-row ones such as grids.

I have not tried myself, but because the implementation of live bindings is interface-based, its potential use extends far beyond DB applications, but you would have to implement the interfaces yourself. It seems to be based around a fairly abstract expression-evaluation engine.

Setting up a l.b. project in the IDE does seem to require quite a bit more clicking around than you'd be used to from a traditional VCL app, but that's mostly because there is an additional step involved where you tell the IDE how to bind the gui objects to the data source(s). However, it is quite straightforward to "wire up" live bindings entirely in code if you want to.

Prebend answered 24/10, 2016 at 20:32 Comment(8)
Hm... Since I am doing only VCL, non-DB applications I am wonder if I can disable LiveBindings package :)Destructor
If you go to Component | Install Packages in the IDE, you should see 3 LB packages next to one another, Embarcadero LiveBindings Components and two others. Remove them if you like, but I'm not sure what that buys you in terms of working in the IDE.Prebend
Probably <1 second faster loading time + fewer properties in Object Inspector. Especially the last one is appealing since there are lots of properties that I never ever ever used. It would be nice if the IDE will put important properties (name, value, position, alignment, caption, text, etc) on top of the list!Destructor
@Silvester: The properties in the Object Inspector aren't going to go away just because you disable the LB packages (which are only used at designtime). The components will not magically lose the LB items, though; those are part of the base classes and aren't going away. And the OI has no way of knowing what you consider important properties, which may be vastly different than someone else's important properties.Asis
LiveBindings also allow you to bind to non-DB related data (lists, arrays, etc.), which the DB-aware controls don't allow. I'll admit to not using LB much, as the vast majority of the code I write and maintain is Win32 (and for most of the small Android apps I write I don't use Delphi), but I can see an appeal to binding items in a list or collection to controls without writing tons of code.Asis
@KenWhite- 1. I have seen applications (PaintShop Pro, I think MS Office also) that sort the menus based on how often you click them. Not a big deal to implement. 2. No matter what you say, some properties are more often used, for example the "Caption" property of TLabel is (certainly) one the most important property when you access the control via IDE. "Name" is also often used. But anyway, the question was about LiveBindings.... :)Destructor
@KenWhite - "and the OI has no way of knowing what you consider important properties" - Embarcadero just implemented the feature that I wanted so much, in Berlin Update 2. It is called QuickEdits: "Increase your productivity with the ability to rapidly modify the name, caption, alignment, layout and color of a control. Also, quickly copy the component name and bind the control to a data source or data field" :) YES. I agree with them. This is an increase in productivity.Destructor
@Silvester: Yes, I'm quite aware of what the question is about, which is why both of my previous comments discussed LiveBindings.Asis

© 2022 - 2024 — McMap. All rights reserved.