jastrachan | 1 Apr 14:35 2004
Picon

Re: Mike on Properties

On 31 Mar 2004, at 23:54, Cedric Beust wrote:
>  Well, thanks Mike for finally delivering.
>
>  I posted a few comments on your analysis in my weblog, but at this 
> point, I think we should take the discussion on this list.  It looks 
> like the JSR EG has their work cut out for them :-)

I just thought I'd answer Mike's conclusions one by one...

	1.  	Groovy properties aren't about fields. They're about what get and 
set methods you have. The bonus case demonstrates that you can have a 
Groovy property with no field at all.

Agreed. Groovy properties are about Java Beans properties.

	2.  	Public fields in Groovy result in private fields in Java. Private 
fields in Groovy result in private fields in Java.

Agreed. You could argue that this is implementation details

	3.  	Auto-generation of get/set methods only occurs for public fields. 
For private fields, you're on your own

Agreed - though why would you use a getter/setter method on a private 
field?

	4.  	Newline sensitivity sucks :-(

Agreed and has been fixed AFAIK

	5.  	A public method that begins with get or set will create a public 
Groovy property whether you like to or not

Not quite. A public method that begins with get or set will create a 
Java Bean property - in Java. This has nothing to do with Groovy - its 
a JVM / Java Platform thing. If in doubt please read the Java Beans 
spec.

	6.  	New public methods that are tacked onto a class can interact with 
existing Groovy properties in ways that can surprise you

Ditto for methods added to a Java class when used with Java Beans

	7.  	There appears to be no way to get a public Java field via Groovy 
code.

Agreed. So far I think this is a good thing :) Though I guess we should 
come up with a way to support this.

	8.  	 The type matching rules on get return types and set parameters 
in terms of how they interact with the property feature is confusing 
and appears not to be well-defined at the moment.

Its well defined - its all in the Java Beans specification. Its the JDK 
which is doing all of this, not us - we just use 
java.beans.Introspector.

James
-------
http://radio.weblogs.com/0112098/

Gmane