pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Volkert <tvolk...@gmail.com>
Subject Re: using annotations for binding between XML/Java elements
Date Wed, 13 May 2009 21:03:42 GMT
> Looking at the usage, it's not really that intuitive to me:
>
>  @Load(name="example.wtkx") private Border border;
>  @Bind(property="border") private Slider redSlider;

Y'know, I had that reaction too and suggested that it look like
@Bind(name="example.wtkx", id="foo"), but Greg pointed out to me that
the caller may wish to load the same WTKX file more than once, in
which case you need to tell the @Bind annotation which loaded instance
you're referring to.

> I would suggest the following
> - default to not needing to specify anything on the @Bind annotation
> if there is only one @load annotation in the class.

It's possible to bind to values that were loaded in a superclass (if
the loaded property is protected or public).  So we can't infer that
the @Bind refers to the @Load that precedes it.  Though we possibly
could make the "property" attribute optional and default it to the
@Load that preceded it.  Greg, thoughts?

> it's not obvious at first glance that the "property" value on @Bind
> actually refers to which @load annotation is referenced.
>
> - rename the property parameter on @Bind to something like
> "loadProperty" or "loadField"

Yeah, it used to be "resource", which was even more confusing :)  I'd
be fine with "loadProperty", albeit more verbose.

> Also the "name" parameter on the @Bind annotation doesn't make sense
> because it refers to the "id" in the wtkx file. Rather just call the
> field "id".

Yeah, this was to maintain parity with WTKXSerializer.getObjectByName,
but your argument just transfers -- why is it wtkx:id but
getObjectByName()?  Maybe it should be wtkx:name...?

Mime
View raw message