The ProblemWe had a Environment class which would choose whether or not to use a webservice (it was set by a web reference) for our authentication methods by reading the host environment and if it was production or the same as the webservice would invoke it, otherwise would run the code before the migration for the webservice.Bad design, poor testing - when working on authentication we manually forced the webservice to be in the same environment we were testing so the webservice would be called.The SolutionThe Enviroment class was killedWe created another webservice equals to the production but hosted on the same environment that calls itAn interface that is implemented by both webservices was designedNow we use a factory to return the right webservice for those who want to authenticate, it is possible due to the interface so if we needed to change the webservice we would only change the new interface accordly.Different Flavours of WrongA person said she'd go with a key in the web.config [I wouldn't use interfaces but the web.config] to return the right webservice but I fail to see how it solve our problem and I don't feel comfortable to argue with/ask her due to politics and our technical skills (newbie me).Here are some thoughts on my mind:Would her key return the correct type for those who seek authentication? If so what would be the interface to authenticate?Would her key be a boolean? In this case I'd need to write an if-else for each authentication method to call the right webservice?Would her key be a string? I guess it could have the host address so only one webservice would be used and one of its proprieties would be changed on-the-fly before calling its methods (I don't know if it is possible, btw)RelevantThe webservice were created on the IDE, we'd not change theirs auto-generated code, but as they also are partials we could implement our interfaces in different files.I didn't find if it's possible to change the entry point of a webreference we generated automatically. The IDE writes methods it has found on that address and it acts as a proxy for the service.The factory helped us to avoid repetitive and unnecessary code, I don't see it happening with other solutions but the string on a key.
A Factory could be replaced by a key on the web.config? How would be the trade-offs of each approach?
c#;design patterns;asp.net;web services
If I understood your colleague's suggestion correctly, the solution proposed was to have a web.config key that contains a type name for the implementation class. You can use this name to retrieve the type, instantiate it (or register in DI container), and use it. I.e.:public interface IAuthenticationBlaBla{    ...}public class WebServiceAuthenticationBlaBla : IAuthenticationBlaBla {...}public class AnotherAuthenticationBlaBla : IAuthenticationBlaBla {...}web.config:<add key=AuthenticationType value=Namespace.WebServiceAuthenticationBlaBla />somewhere in the initialization code (using DI, Autofac in this case):ContainerBuilder builder = new ContainerBuilder();...builder.RegisterType(Type.GetType(ConfigurationManager.AppSettings[AuthenticationType]))    .As<IAuthenticationBlaBla>();