Indeed, Tor. Properties doesn't just mean "nice sugar so I can make x = 0 really mean setX(0)". It also means seamless support for propagating changes, including the ability to bind two properties together.
I find JavaFX's solution particularly elegant, and when we get around to adding property support to lombok, we're likely going to pattern it around that and not the beans jsr. On Sep 18, 7:37 pm, Tor Norbye <[email protected]> wrote: > Right. Just to expand a bit further on this: A field plus a getter and > setter isn't -really- what we mean when we say we want -proper- > property support in the language. Think of a GUI component instead, > such as as a slider. I want -client- code to be able to do this: > > slider.min = 0; > slider.max = 100; > slider.value = 50; > .... > // and to read slider: just reference slider.value > textBox.content = bind Integer.toString(slider.value); > > This can't just be a public field because things need to be organized > such that when you set the property the UI representation of the > component updates itself. > > With old JavaBeans this was done with special code in the setters > which would fire property change listeners (that the view listeners > listen for). With JavaFX properties are directly supported in the > language so it's using various bind-machinery to handle this. > > The point is that for real properties you can't just use a field; in > Java you need to use proper setters -- which means you don't get the > nice uniform access shown above. In languages that support properties > this works nicely. > > -- Tor > > On Sep 18, 7:15 am, Cédric Beust ♔ <[email protected]> wrote: > > > > > On Sat, Sep 18, 2010 at 1:30 AM, Steel City Phantom > > <[email protected]>wrote: > > > > you can implement that today in java. its very easy to do so as well, > > > heres how > > > > public class haha { > > > public String name; > > > } > > > > there, now you can do your a.name = foo. not very hard. > > > Please reread my post more carefully. If one day you decide to add a setter, > > clients of your code who wrote "a.name=foo" won't go through that setter. > > > -- > > Cédric -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
