Re: Separate interface and implemenation problem..
On Thu, 4 Jun 2009, Mark Space wrote:
Lew wrote:
Static methods go against the point of interfaces, since static methods
cannot be inherited. You get everything you need from static methods
in a utility (usually non-instantiable) class anyway.
As Steven picked-up on, my intention was to define a kind of interface for
static methods, not replace classes of static methods with interfaces. I
think such an static interface would be useful for various kinds of factory
patterns.
// not real code
public static interface MyFactory {
MyObject makeObject(); // implicitly static and public
}
//...
public class MyObject implements static MyFactory {
public static MyObject makeObject() {
...
}
}
Or something like that...
This is a perennial problem. Here's what i came up with five years ago:
http://c2.com/cgi/wiki?ConstructorObject
Thinking about it, though, another solution would just be to load a
factory class, Class.newInstance it, and then get instances of the class
of interest from it, without ever addressing the class of interest
directly.
tom
--
It involves police, bailiffs, vampires and a portal to hell under a
tower block in Hackney.