The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
Thank you and the rest of the CP staff for making codeproject.com a nice place to hang my programming hat. The folks here and the articles they freely provide have helped me out more times than I can count. We do appreciate the hard work you, the staff, and the hamsters put in.
So I just spent an hour figuring out why I was getting an exception in my application when using a third party library to communicate to a credit card processing machine. I was getting a general exception back from the third party library, but the test software that comes with the library was working just fine.
Short answer, when I C&P'd my router's public IP address into the dialog box, there was a space at the end of the IP address. Took a while to spot:
Sigh. OK, so now I make sure to trim the IP address string (the third party library expects a string) and I suppose I should do some regex validation.
Still, why couldn't I get back an exception like "malformed IP address"? Why is the library so sensitive to an space at the end of string? Yes, I take some responsibility, but not all the responsibility!!!
when I C&P'd my router's public IP address into the dialog box
Copy & Paste, indeed! I expect more from you. You should be typing more. Trim()
I never trust user input because I used to do a lot of testing and open input boxes are the best way to break a program.
Summary, every time a cop didn't have the license plate for the ticket a NULL got entered into the database for the license plate. That meant all ticket fines got assigned to the owner with the license plate of NULL.
I faced something similar yesterday in one of my scripts. The string '1E2-' was validating as numeric...which it is...in hex!
To be fair, if the expression had been entered correctly as either '1' (a single position) or '1E2:-' (an expression) it would have been OK. However, it should have reported the expression error (missing param separator) instead of saving the incorrect value. It was a 10 minute fix and I caught it before the customer!
Stringly typing never seems to get out of fashion.Strict typing can be a pain at times, but in the end it's one of your strongest allies. Taking the lazy way out breeds so many small and large horrors, but why waste a thought on it when they waste other people's time?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
Those trailing space problems get worse when SQL Server gets involved, or the way we have it set up anyway. While a string with a trailing space is completely different to one without in .NET, TSQL matches them both. Causes a key-caching nightmare when not validated!