JavaFX and the Missing Interfaces

Anthony Vanelverdinghe anthony.vanelverdinghe at gmail.com
Tue Nov 6 09:36:32 PST 2012


+1

Adding generics you 'd get:
interface IControl<T extends Control> {
     T getControl();
}

Another option is to rewrite your method signatures from
public Something fooBar(IControl control) {...}
to
public <T extends Control & IControl> Something fooBar(T control) {...}

So there are already solutions to the problem. In my opinion, interfaces 
like the ones proposed are neither necessary nor desired (as Richard 
already pointed out, they would unnecessarily clutter the API).

Kind regards
Anthony

Op 5/11/2012 21:46, Pedro Duque Vieira schreef:
> I've read your blog post.
>
> May I suggest doing:
>
> Interface IControl
> {
>    Control getControlRepresentation();
>    (...)
> }
>
> This way you enforce every implementing class to have a Control
> representation. And also as a plus you don't need to recur to casting when
> you need to call methods from Control, because you can get a Control
> representation via getControlRepresentation(). This is basically
> composition instead of inheritance, which I think IMHO is better most of
> the time.
>
> Also one more note, the methods of the API are final because of security
> reasons. I guess Java is to blame for this.
>
> My 2cents, best regards,



More information about the openjfx-dev mailing list