I have an interface:
public interface MyInterface{}
And two implementations:
public class Imp1 implements MyInterface {}
public class Imp2 implements MyInterface {}
My program is a CLI. I want to have some class, which would take command-line args, parse it and create new instance of correct implementation:
public class MyFactory {
public MyInterface getMyInterface(CommandLineArgs args) {
....
}
}
Is there a pattern to use here? I am not sure that abstract factory pattern suits it, as I have only one implementation of the factory.
If it is not the correct way to do it (why?), then how it is more acceptable to do it?
Thanks in advance