Quantcast
Channel: Question and Answer » web-services
Viewing all articles
Browse latest Browse all 136

A Factory could be replaced by a key on the web.config? How would be the trade-offs of each approach?

$
0
0

The Problem

We 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 Solution

  1. The Enviroment class was killed

  2. We created another webservice equals to the production but hosted on the same environment that calls it

  3. An interface that is implemented by both webservices was designed

Now 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 Wrong

A 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)

Relevant

The 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.


Viewing all articles
Browse latest Browse all 136

Trending Articles