How to switch between implementations of my SomethingManager class?-Collection of common programming errors
I have an app which has OrgManager interface, which has a yet-to-be-built OrgManagerImpl
The OrgManagerImpl has to go and talk to some REST API 3rd party stuff which we don’t have access to yet.
So while I am testing the web front end, I have written a mock OrgManagerImpl that implements the OrgManager, but at go-live I will need to swap that implementation over.
However now I am in the situation where I want to have the servlet select its OrgManager implementation dependent on some condition.
Also when I call myOrgManager.findCompany(“SomeCompanyId”) I want myOrgManager to go and look at all the possible implementations to find the company and make a big list.
Also I would like when I do myOrgManager.createCompany(company) to prefer one implementation over the others.
I seem to be heading towards a UserManagerManager object… but I feel that this is likely missing some point of Java or Object orientated design that I should know about.
Can anyone suggest a pattern, or strategy that I should be using instead?
Thanks