I have code that looks like the ff.:
Interface i; if (someCondition) { ImplementationA a = new ImplementationA(); a.setFieldA(someValueA); a.setFieldB(someValueB); i = a; } else { ImplementationB b = new ImplementationB(); b.setFieldC(someValueC); i = b; } // Do something with i. My questions are:
- Should I use dependency injection here or is this beyond the scope of the technique?
- If I should use dependency injection here, how can I accomplish it using Google Guice?