The Great Property Debate
Posted by
Scott Delap
on
Jan 08, 2007
- Java
- Topics
-
Change
- Tags
-
Java SE
Giving closures a break to start 2007, the Java community has taken up the topic of properties in recent days. A
flurry of commentary revisiting the possibility of a property keyword and arrow operator has appeared. The discussion seems to have started largely as a result of a
presentation at Prague JUG by
Danny Corward, JavaSE Platform Lead. In the presentation he floates the idea of a few language additions related to properties in Java 7:
public property String foo;
a.setFoo(b.getFoo());
a->Foo = b->Foo;
This resulted in a number of comments against arrows.
Jacob Hookom wrote:
...I'm of the opinion that if you are willing to make a commitment to closures, then we do the same for properties-- something similar to C#. Spending time extending the long winded get/set convention is the wrong direction for the spec. Do everyone a favor and do properties right-- leaving the old Bean Property spec alone for APIs to accommodate and treating properties as a first class citizen in the metadata starting in SE 7...
Kirk commented:
...If this syntax can on encourage behavior that we don’t want than why on earth would the authors of the JSE 7.0 JSR propose such a change? My real answer is; since I’ve not spoken to the authors I don’t really know. However the evidence is the use case is ease of use for Java beans. Simply put, the spec lead for the next version of Java would like to change the language to handle an edge case while ignoring the potential of creating havoc in just about every other language use case...
Moving past the arrow for a moment Cay Horstmann provides a recap of the entire situation and mentions issues found along the way. In summary he writes:
Before vilifying a proposal because of unsightly syntax, let's summarize what one wants in native properties.
- The common case--a private field and public getter/setter pair--should require minimal boilerplate.
- It should be easy to supply getters and/or setters that do some other work.
- It should be easy to specify read-only or write-only properties.
- Javadoc should document properties.
- There should be reflective access to properties.
- Properties need to integrate with annotations.
Here are some issues that have been raised.
- Should getters and setters of native properties be regular methods?
- Should native properties be compatible with JavaBeans properties?
- Should there be support for bound and vetoable properties?
- Should properties have other than public visibility?
The issue that has gotten the most press, namely what operator, if any, to use for property access, seems the least important one.
Syntax
by
Jonathan Locke
Posted
Jan 8, 2007 9:59 AM
Re: Syntax
by
Hernan Parra
Posted
Jan 8, 2007 2:46 PM
Re: Syntax
by
Patrick Linskey
Posted
Jan 11, 2007 8:10 PM
Re: Syntax
by
Richard L. Burton III
Posted
Jan 12, 2007 10:01 AM
Re: Syntax
by
Patrick Linskey
Posted
Jan 12, 2007 11:00 AM
Re: Syntax
by
Richard L. Burton III
Posted
Jan 12, 2007 11:22 AM
Re: Syntax
by
Patrick Linskey
Posted
Jan 12, 2007 12:18 PM
Re: Syntax
by
Richard L. Burton III
Posted
Jan 12, 2007 12:41 PM
Re: Syntax
by
Richard L. Burton III
Posted
Jan 8, 2007 4:27 PM
Re: Syntax
by
Jonathan Locke
Posted
Jan 8, 2007 6:02 PM
Re: Syntax
by
Jean-Baptiste Potonnier
Posted
Jan 9, 2007 3:02 AM
Re: Syntax
by
ZedroS Schwartz
Posted
Jan 9, 2007 7:08 AM
Re: Syntax
by
David Skelly
Posted
Jan 9, 2007 7:28 AM
Re: Syntax
by
ZedroS Schwartz
Posted
Jan 9, 2007 7:54 AM
Re: Syntax
by
Richard L. Burton III
Posted
Jan 9, 2007 10:04 AM
Re: Syntax
by
Jonathan Locke
Posted
Jan 9, 2007 12:02 PM
Re: Syntax
by
Richard L. Burton III
Posted
Jan 11, 2007 1:01 PM
Re: Syntax
by
Jacob Hookom
Posted
Jan 9, 2007 12:43 PM
Re: Syntax
by
Cedric Beust
Posted
Jan 11, 2007 6:39 PM
24 comments
Watch Thread Reply