In order to learn more about this, I wanna ask for the best path
What I have
- I’m consuming 2 web services, one for a version 1 and the other for a version 2
- In code I use each version by a integer in the client table,
client.ws_version = 1 or 2
.
IWebServiceRepository repository;
if(client.ws_version == 1)
repository = new WebServiceRepositoryVersion1();
else
repository = new WebServiceRepositoryVersion2();
What I have learn
That this is the worst thing to do 🙂
So the question is What’s the best way to accomplish this? Facade? Dependency Injection? other process?
If the statement is that simple its not actually a bad way to go, but you should encapsulate your statement in a
WebServiceRepositoryProviderCode:
You can configure this functionality with many inversion of control containers, but it would be overkill to implement DI in your app for such a simple function.