Protip
- July 27th, 2010
- By AMB
- Write comment
Never require the presence of a variable which isn’t used in your code.
I would think this would go without saying, but I just lost most of a day trying to figure out why a web service wasn’t working. One of the things I’d done was cleaned up some old code, including removing a hardcoded HTTP header value. The header it referenced wasn’t consumed anywhere in my code, and a quick smoke test indicated that, no matter what the value was set to, the client services behaved nicely. So I assumed (correctly, as it turns out) that the variable wasn’t used in locally or in any system in which we integrate, so I cut the reference out.
Rolled up the build, sent it off, moved on to other things.
QA failed the build, because one of the integration use cases was broken.
Turns out that unless that header is present, one of the methods in a client web service dies. It doesn’t matter what the value is, but it has to be there, or the web method chokes.
So, moral of the story: make sure that all your variables are really needed. Make sure they they mean something and cut out any variables which aren’t required. This is especially true with integration situations like those found in web methods.
