On Thu, 22 Apr 2010, Alejandro Vilar wrote:
Hi Michael,
You right about the "constant" meaning of this anti-pattern, but I'm talking
more about implementations into interfaces. An example could be:
public interface ComponentListener{
//...methods
}
public class Adapters{
public static class ComponentListenerAdapter implements
ComponentListener{
//...empty implementations
}
}
import static Adapters.ComponentListenerAdapter;
public class Foo {
void bar() {
ComponentListener l = new ComponentListenerAdapter();
}
}
I'm too lazy to compile it, but I don't think this is right. "static
imports" are for importing constants. ComponentListenerAdapter is not a
constant. I think the line you want is
import Adapters.ComponentListenerAdapter;
//versus current
public class Foo {
void bar() {
ComponentListener l = new ComponentListener.Adapter();
}
}
You can just do the same thing as above to reference "Adapter" directly:
import ComponentListener.Adapter;
Although I'd rather leave that name qualified, it being so generic.
Hmmmm... I don't see any trouble here. I think the Pivot design is
perfectly rational, if not optimal.
Cheers,
Michael