J
java-john
I have a class that uses composition of interfaces. I want to be able
to allow users to decide at run-time which implementations of these
interfaces to instantiate. What is the best way to do this? Are there
any frameworks out there? Is there some design pattern for this?
For example:
public interface MyInterface {
public String getValue();
}
public class MyClass {
private MyInterface myInterface;
public MyClass() {
myInterface = new SomeRunTimeImplementationOfMyInterface();
}
}
to allow users to decide at run-time which implementations of these
interfaces to instantiate. What is the best way to do this? Are there
any frameworks out there? Is there some design pattern for this?
For example:
public interface MyInterface {
public String getValue();
}
public class MyClass {
private MyInterface myInterface;
public MyClass() {
myInterface = new SomeRunTimeImplementationOfMyInterface();
}
}