Skip to main content

Beans Binding and my Flex friend

Posted by joconner on March 23, 2008 at 10:53 AM PDT

Beans Binding

I recently wrote a brief introduction to Beans Binding called Synchronizing Properties with Beans Binding. I was enthusiastic about Beans Binding, and then a coworker threw a wet towel on me. The conversation went something like this:

John: I just finished an article on This API might be useful in this project.

Coworker: Yeah, what's that?

John: Beans Binding. It's an API that will help us bind beans together, synchronizing properties.

Coworker: What do you mean?

John: You know...say you want to update a table with new data anytime a result set changes, or maybe you want a price field to display the current total of all purchased items in a shopping cart. You can use beans binding to synchronize the properties without having to write all the plumbing and event handling yourself.

Coworker: Hmm. Java hasn't always had that?

John: Well, yes. Java has always allowed you to synchronize properties, but we've never had an API to make it this easy.

Coworker: Really? We've had this in Flash and Flex forever.

John: You've had binding?

Coworker: Binding, or Beans Binding...whatever you call it. We can bind a variable or property to another variable or property so the updates trickle throughout the application. It's a great feature, a must-have, and I couldn't do without it. I use [Bindable] among other things.

John: Yes, it's great. I agree. So take a look at that article. Beans Binding, it's pretty cool.

Coworker: You're just getting binding in the Java language? Hmm... really? I just assumed Java would have had that all along.

John: Um, it's not exactly part of the language. It's a new API. Making changes to the language is difficult and usually takes a long time...

Coworker: Oh, I misunderstood. It's not part of the language? Just a separate API? Got it. Hmm...ok. Well, uh, gotta run.

John: Hey, wait. But Java FX Script has a bind keyword that is part of the language. Remember? I told you about Java FX Script earlier.

Coworker: Right. Java FX Script. It's about time Java got got a bind operator or keyword, something.

John: No, not Java. Java FX Script. That's the new language for rich client app development. Java FX Script has the bind operator. Java has the Beans Binding API.

Coworker: OK, right...well...hey...I have to get back to work on this Flex app. But I agree, binding is great, couldn't do without it, use it all the time.

Related Topics >>


"...because obviously you haven't..."

Well, sometimes things aren't so obvious as they seem:-) In fact I have used JavaFX and I'm using it. I like the binding stuff so much that I've recently designed a set of components in Java by using the same paradigm, even for "driving" JPA (see some of my older blog posts, even though I'm not yet finished with it). Of course in Java there's no "bind" keyword, so I used BeansBinding: the point is that the feature is important to me, not necessarily the keyword (even though, like I said, BeansBinding could offer something in an easier way). I dare to say more: I prefer to write some more lines of code, but knowing what's happening, rather than using a magical keyword and trusting the unknown. With BeansBinding, when something doesn't work or when I have some explosion of objects, I can just fire the debugger or the profiler, and eventually get to some forgotten removePropertyChangeListener() or I discover I have to use some WeakListener to fix the thing. WIth JavaFX I don't know how to do that: is it possible?

Of course, it's probably a matter of perspective. JavaFX, just as Flex, is used to create quickly a User Interface, and probably you don't run into stuff with ten thousands of floating objects. So, perhaps the typical JavaFX programmer just doesn't run into troubles. BTW, let's take this with a pinch of salt, as I never had to do complex things with JavaFX - did somebody do? I wonder how the thing could scale.

I'm not sure having a special keyword as in JavaFX made life really better for the programmer. Fabrizio, will all due respect, I think you try JavaFX first before you pass such a judgment about the the usefulness of the bind keyword, because obviously you haven't. Binding in JavaFX is as much a paradigm shift in programming productivity and ease if use, as automatic garbage collection was as such with Java. I speak from past experience with both languages.

It's a recurrent discussion with some of my friends too. While I would like to have something in the BeansBinding API to be simplified, I'm not sure having a special keyword as in JavaFX made life really better for the programmer.

Flex [Bindable] avoids event listeners, (ugly innerclasses) adding removing listeners.GUI development is alot easier with [Bindable] . Other than Binding there are also other great features, like quickly develop custom components..

After working on Flex for one project, I dont want to comeback to Swing development :)

Gee and were are just starting to approach the point that NeXT was at in the early 90's with Objective-C and Interface Builder.

It's really sad how long it takes for those good ideas to propagate.

Java should have had Beans Binding a decade ago.

@jtp51, I'm not sure this is a total language comparison. The point I think I'm conveying is the unenthusiastic attitude. As great as some things are getting in the Java world, some other environments have had similar or better features for a long time. Our great strides in Java appear unimpressive to some people. In particular, this particular colleague wasn't impressed with Beans Binding in Java or bind in JavaFX Script...he had used that functionality in Flex for a long time.

You're coworker was comparing Java to Flash/Flex?

You could have always asked him about thread support in Flex. Trust me there are plenty of wet blankets to throw around.