I'm looking into Guice and I've been reading its documentation recently.
Reading the motivation section I don't understand the factories part, why they name it that way. To me that factory is just a wrapper for the implementing class they want it to return after calling getInstance().
public class CreditCardProcessorFactory {
private static CreditCardProcessor instance;
public static void setInstance(CreditCardProcessor creditCardProcessor) {
instance = creditCardProcessor;
}
public static CreditCardProcessor getInstance() {
if (instance == null) {
throw new IllegalStateException("CreditCardProcessorFactory not initialized. "
+ "Did you forget to call CreditCardProcessor.setInstance() ?");
}
return instance;
}
}
Why do they call it factory as well if it is neither an abstract factory nor a factory method (at least as they were originally defined by the GoF)? Or am I missing something?
Thanks.
EDIT: if someone comes up with a better title, I'll be glad to change it.