- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
First?
And no, this is not spam, you soulcrushing scrip!
Admin
This comment is very important. DO NOT TOUCH!
Admin
bool memberHasFirstComment = bool.Parse(bool.FalseString);
Admin
That's what she said.
Admin
That is not the worst way to set a boolean to False. Something like this would have been "less good"
bool memberHasFingerprint = !bool.Parse(bool.TrueString);
And I'm sure someone creative enough could come up with something worst yet.
Admin
Seems like this programmer had a bit of a potty mouth...
Private Function FnPtrToLong(ByVal lngFnPtr As Integer) As Integer
Admin
throw new AccessViolationException("Ouch, that's cold");
Admin
Admin
Really? Replace them when you see them? You would think there would be an automated way to "find and replace" such "atrocities" with such a useful "fix". Nevermind the fact that this fix is as least as dumb as the original. At least.
Admin
The loop makes it more random, you see...
Admin
Actually I remember doing something like the 'pointer to long' in fortran on VMS once
IIRC fortran didn't have pointers but it was possible to call C functions like malloc. however, the only way to get the return value from malloc into an int was to hide it inside an additional layer of function call because fortran is less funny about type coercions across function boundaries
but of course if that example wasn't VMS fortran then it is a WTF ;-)
Admin
A good developer never forgets about FileNotFound.
bool memberHasFingerprint; try { memberHasFingerprint = bool.Parse(FileNotFoundString); catch (FormatException) { memberHasFingerprint = !bool.Parse(bool.TrueString); }
Admin
bool memberHasFingerprint = (bool.Parse(bool.TrueString) == !bool.Parse(bool.TrueString))
(i can feel the slippery slope coming on)
Admin
Aaron's code comment feel deja vu to me from one project I endured many moons ago... like man, it does speak to me, like, literally!
Admin
Admin
FTFY. Even more random now.
Admin
Looks like oneHundred can be anything except 100.
Admin
Admin
bool memberHasFingerprint = true; // set fingerprint presence to false...
Admin
Admin
He just learned the coalesce operator and he wants to use it everywhere.
Admin
Admin
Why test if an empty string is empty (if s is null)? Seem like inlining the code from the original functions would be better. Which is probably what the compiler does anyway. And it's more readable. Once again the suggested fix is TRWTF.
Admin
Well, I'm all in favour of comments which explain why code was written in a particular way. Aaron's predecessor's comment isn't quite what I usually have in mind, but at least it heads off all the folks around here who cry "what the hell were they thinking?"
Admin
Admin
I remember that one. French guy had to see the site in English. (some sort of language preference was just too easy)
Admin
Admin
bool memberHasFirstComment = bool.Parse(bool.FalseString);
users.NotFirst.comment = bool.Parse(memberHasFirstComment);
Admin
Got that in code I had to maintain (another language, but still):
Admin
Fixed it for you
Admin
.. whew! cuz I thought it was from someone in my place. I certainly recognize that number! ;
Admin
Admin
Admin
But, FnPtrToLong neither accepts nor a returns a long. Both are integers, no?
Or was that the WTF?
Admin
Priest function?
Admin
"[D]evised by IT iliterate[sic] decision makers without a clue what it's[sic] should do or who wants it."
Was he being ironic?
Admin
Ok, I've never seen this operator before. Yes, it is a flash of ignorance on my part, though a quick check through the code base of my company's code (and there have been a fair number of C# developers here) I can't find a single instance of it being used. Why, we just didn't, collectively, know it. Mind you, most of us got our degrees while programming in Java or C/C++ so maybe it is just that it wasn't part of those languages. Either way, it's not really a WTF. It's a failure of knowledge rather than technique.
Admin
Admin
Nah, he's just an ancient Greek. It's cool. They touch the colons of boys all the time.
Admin
Admin
Yeah I don't think so. Sarcasm involves intentional irony and humor. Show me those two elements.
Admin
What we are looking at here folks are samples from the pioneers of coding. If it weren't for these idiots, why we wouldn't have the super idiots we have today.
Admin
Actually, it turns out that the longer version of the IsNullOrEmpty() test that Anthony Arnold reported was needed in earlier versions of .NET. See:
DANGER ! String.IsNullOrEmpty can lead to runtime Null exceptions !!
So which is the bigger WTF here: Writing it this way? Or having to write it this way because your compiler doesn't optimize right?
P.S. ...and, to top it all off, Anthony might be doing the wrong thing. Let's hope his compiler works right.
Admin
I don't think it existed before the introduction of nullable types in C#. I wasn't familiar with it either having start with .NET 1.0.
Admin
Anthony's method is functionally equivalent as far as null checking goes. TRWTF is having a method called "IsRealString" that checks an object instead of a string. In other words, the call to .ToString() is the fly in the ointment here.
Admin
Oh, wait. This is a forum on the internet, so no one cares.
My mistake.
Admin
What, so you guys don't touch your colons? Boy, are you missing out.
Admin
oracleDbPortNum = 1521
Admin
on the other hand, they could do it like this: eval(file_get_contents('othersite'));
Admin
Unless it starts out at 200 ...