C
Chris
How do I force a class to have certain static methods?
Here's the problem. Our system has certain pluggable classes. To make a
new implementation of such a class, you just have it implement a certain
interface.
I want to have these classes have certain static methods like getName()
and getDescription() that just return constants. The trouble is, you
can't put static methods in an interface. You also can't have static
abstract methods.
I could make these methods non-static, but then you'd have to actually
create each class just to get its description, and that's an expensive
process. The classes can contain data structures that are quite large.
What's the workaround?
Here's the problem. Our system has certain pluggable classes. To make a
new implementation of such a class, you just have it implement a certain
interface.
I want to have these classes have certain static methods like getName()
and getDescription() that just return constants. The trouble is, you
can't put static methods in an interface. You also can't have static
abstract methods.
I could make these methods non-static, but then you'd have to actually
create each class just to get its description, and that's an expensive
process. The classes can contain data structures that are quite large.
What's the workaround?