[REVIEW] Make controller instantiation customizable
Greg Brown
greg.x.brown at oracle.com
Fri Dec 16 15:31:43 PST 2011
> if we supported the alternative (named parameters declared on the FXML side) we might actually have a better all around solution
As I mentioned in my previous message, I don't think this is either necessary or a good idea, since it would seem to violate the intent of IOC.
> FWIW, if we do go with the ControllerFactory, then we really should make it a Callback rather than a separate interface.
While this would work from a strictly technical standpoint, I don't think it is the best option in terms of readability. It's pretty obvious to me what a ControllerFactory does - an implementation of this interface is obviously going to produce controllers based on a given type:
public interface ControllerFactory {
public Object getController(Class<?> type);
}
OTOH, this is pretty ambiguous:
public interface Callback<P, R> {
public R call(P param);
}
A developer will have to look a lot more closely at the Javadoc for setControllerFactory() to understand what a "callback" is in this context, and what call() will actually do. A dedicated interface is clearer, yet will be equally applicable to lambdas in Java 8.
More information about the openjfx-dev
mailing list