Sun Java Designers Distancing From Property Syntax
It took 34 days since the initial posting (and my reporting), but it seems that some of the Java language designers and other Sun folks (Ahé, Buckley, Muller) are moving away from the syntax for properties.
I believe Hans Muller's post asked the most fundamental question: What are properties for?
And if I remember correctly, the properties concept came into Java through the JavaBeans specification in JDK 1.1. It was supposed to be an abstraction layer of the underlying mechanisms for GUI builders, like Microsoft's COM. Properties, together with the concept of methods and events form the foundation of a GUI component system. And of particular utility are a couple of combinations of properties and events: the bound properties and constrained properties.
So properties, in that context, does something useful. For example, when you set the text property on a Label, it will have go find the appropriate glyphs from its font and erase the old text and paint the new text.
Somewhere along the line, the concept of properties were subverted. It became a mindless chant:
// Exhibit A public int foo;is not OO! Change it to
// Exhibit B
private int foo;
public void setFoo(int value) {
this.foo = foo;
}
public int getFoo() {
return foo;
}
to make it OO. And along the way, we, with our favorite IDEs as accomplices, managed to bloat the world total Java code base by about 10% (maybe more).
It is these IDE-generated, boilerplate, pointless bloat that most people hate. And we wish we can do
a.foo = b.foo;instead of
a.setFoo(b.getFoo());
Well, there is an obvious solution to this (minor) gripe. Can you guess what it is? You're right. You can accomplish this goal without addition to the Java programming language. You can simply turn all instances of Exhibit B into Exhibit A. There should be a refactoring called "Remove frivolous getters and setters" that does it automatically.
Go ahead and do it. Should take about ten minutes.
You done? Did it break your app? Probably not.
Do you have any getters and setters left? If not, you're done. And you can go home now.
The remaining getters and setters are the true properties. Now stare at them for a minute. (Here's an example from the JDK:
public void setNextFocusableComponent(Component aComponent) {
boolean displayable = isDisplayable();
if (displayable) {
deregisterNextFocusableComponent();
}
putClientProperty(NEXT_FOCUS, aComponent);
if (displayable) {
registerNextFocusableComponent(aComponent);
}
}
from javax.swing.JComponent.)
Still feel like some syntactic sugar for properties? Go ahead and add some. (Here's a tip: the Microsoft folks have property support in C# for six years. I wouldn't mind that syntax!)
Finally Upgraded To Fedora Core 6
It has been 79 days since Fedora Core 6 was released. I finally got a chance to upgrade my work station from FC5 to FC6.
As in the past, I downloaded the FC6 x86_64 DVD using Bittorrent, and started my "try upgrade first, if that doesn't work, do a fresh install."
The upgrade worked. It took about 2 hours for all the new packages to be installed from the DVD to the hard drive. And then it took a full day to pull down all the accumulated updates using "yum update" from the Fedora mirrors. As in the past, I relied upon the Fedora Core 6 Tips & Tricks website to get the multimedia stuff installed.
Improvements that I've noticed include:
- The Istanbul Desktop Session Recorder is improved tremendously. Last time I tried it, it was very primitie. The version in FC6 feels a lot smoother, and did not use a huge amount of memory or CPU as the FC5 version did.
- I just noticed the Cups-PDF printer driver that allows one to print anything to a PDF file. (This might be already present in FC5.)
- The GL-accelerated desktop effects are cool. My windows wobble when moved, and my workspaces are on a cube (that rotate in 3D) now. It also has something similar to the Mac OS X Expose.
- The Gobby collaboration editor looks like it should be useful. It supports distributed file editing with chat.
- I switched to 32-bit Firefox just to get Flash working. I can watch videos on YouTube now.
- And as you can see in the screenshot below, Qemu still works.