- 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
Finally, production code that produces an error message recreating part of my reaction when some Java or C++ code fails to compile. I usually throw in a few obscenities, though, just for the heck of it.
You know what? I think I can make this better...
try
{
/* SNIP: 15 lines */
}
catch
{
//How did this happen??
log.fatal("WTF???????????????????????????");
}
Admin
the real WTF is that 1900 is not even a leap year. dork!
http://www.dpbsmith.com/leapyearfaq.txt
Admin
I'm ashamed to admit that I've done the zero-padding code before, but in my defense it would only pad one or two zeros to the front of a number string. Then I learned about
Do Until Len(myNumStr) >= 5
myNumStr = "0" & myNumStr
Loop
I can't believe it's not butter.
Admin
And he got it wrong! The formula isn't tough...
In no particular language (Year%400 == 0) OR ((Year%4 == 0) AND NOT (Year%100 == 0))Nice use of fall through. It is almost 'case' like. If it isn't someplace where I care about performance or memory management, I'd leave it just for its aesthetic qualities.
Admin
For this coder, it is always September 19th.
Admin
or
int myNum=12345;
System.out.println(("0000000000"+myNum).substring((myNum+"").length()));
Admin
Why doesn't anyone stick up for support? That's only 4 letters difference!
Admin
<font size="2">He misspelled "Aaaaaarrrgghhhh".</font>
Admin
I think Alex forgot to post the rest of this conversation. I'm sure it goes something like this...
Support: What do you mean C and COBOL are different "languages"? They're both in English, I think.
Chris: *&$#@*%#
Support: So you mean C is not short for COBOL?
Chris: *$&#@*$#
Admin
I occasionally use errors like this, especially when debugging an application. Provided that every 'unprofessional' error message is unique, such expressions are very easy to search for in the source code. A search for 'error' might give you 100 matches, but 'Aaaaarrrgghhhh' is most likely to give just one match.
From production these are of course removed, since they are unprofessional.
Admin
This is neither a configuration nor a code problem, it is a philosophical problem. Or rather, a non-problem, because IsValid is of course trivially true.
Admin
Equation to see if it is "far enough":
((truncate(((60 - current age) + current year) / 10)) * 10) + 20 (to not screw the next gen too)
code for that current year was probably 2003
which puts that programmer between the ages of 14 and 23
Admin
How many times does an error message have to be used, before it gains professional status? Or is it governed by a certification test? </humor>
Admin
I've done something like this before. Except it wasn't for 9999-digit long numbers, and there was no for-loop involved. I was using some scripting language I wasn't familar with and didn't want to look up the equivalent of printf() to just pad a number so that it was 3 digits long, so i just did something like the first two if statements.
And I immediately saw the WTF about the year 1900, but then I saw that several other people had beaten me to it. :)
Admin
You've obviously never experienced the joy of having some profainty get tossed to the screen during a customer demo. Or having a system password, also a profainty, make it into the final documentation.
Admin
Nowadays, I hardly every write UI code, but early in my programming career (10+ years ago now), I wrote a program that did a lot of input validation. And, for various reasons, it was completely text based. No windows or other UI doo-dads. It was written in completely portable C++ and just used iostreams.
All the input validation messages were very chatty and somewhat silly. They were to the point, and it was obvious what it was complaining about each time, but the tone of the messages was that of a good friend chiding you over a silly mistake.
The company I worked for was pretty small, and I was the only person on their staff who knew much of anything about the inner-workings (hardware or software) of computers. So the program went into production that way.
I ended up having to change all the error messages to be 'boring' anyway though. One person on staff complained that in order for him to maintain his professional demeanor and focus in the office, the program had to report the error messages in a dry, neutral tone.
I was both amused, and slightly irritated. But I did it. :-)
I sort of think people get way too uptight about stuff like that. I don't really understand why a program can't say "Arrrggghh!" as long as it doesn't confuse anybody.
Admin
Why all that "if"s if you know the number is always 4 digits long?
Admin
The board eats half the code...
Admin
How do you feel about the message "Holy Bat, Fuckman, how did we get here?", which I accidentally left in code that got to a production server?
Admin
Personally, I'd take a screenshot, and mail it to a bunch of friends.
Admin
I'd have to see all the code.... but it looks like at the end of the loop you're left with:
limit = 9999
i = 9999
number = "009998" (more 0's depending on how many alex snipped out...)
and a heck of a lot of wasted cycles for iterating from 1000 to 9999
wtf??? I hope there's more to this than I can see...
Admin
Admin
ummm... it has been a long time since I've coded PHP, so I am probably exposing my gross ignorance, but how does the original code ever produce anything but '09998'?
Admin
MP!
Admin
The "Aaaargh!" error is better than one program I had to debug that simply said "Something Wrong".
Admin
Its also better than "Something didn't quite work out."
Admin
/*
Is the object's validity not implicit in the asking of the question? If it were not, would we be asking the question? It's a very anthropic situation that is far too complicated to discuss in code comments, please refer to the product documentation for more insight.
*/
<font color="Red"> Something didn't quite work out ...
- CAPTCHA Validation Incorrect </font>
Admin
Or
myNumStr = String("0", 5 - Len(myNumStr)) & myNumStr
Admin
Oops, got the arguments backwards:
myNumStr = String(5 - Len(myNumStr), "0") & myNumStr
Admin
And thus was born Alex's screenshot fridays. =D
Admin
please note that it produces 01000 through 09997 in the meantime.
i would think that the [snip] removed non-wtf-relevant code which was processing the numbers
Admin
Admin
And (s)he's the dork?
Admin
Why not Format( CInt(myNumStr), "000000")?
I don't have VB installed at the moment so can't test it for correctness or efficiency, but I think it's slightly clearer in any case.
Admin
Admin
If you wanted to keep it in PHP (which I assume the original WTF is written in) you could simply write.
$padded_number = str_pad($number_to_pad,$pad_length,'0',STR_PAD_LEFT);
Makes more sense that way I think.
Admin
I am assuming that the number-padding code does something with the padded numbers in the snipped part of the loop...otherwise it would be a monumental waste of time.
And yes, it's PHP. (It could also be valid Perl, except that Perl requires curly brackets around if statements with a single body statement.)
Admin
The real WTF in that second one is the misspelling of "license".
Admin
Ding! Ding! Ding! Ding! We have an analyst trolling! We have and analyst trolling! Ding! Ding! Ding! Ding!
Admin
Speaking of unprofessional error messages, a few months ago I was trying to teach a coworker how to use CVS. We use a CVSNT service as our repository. She was having lots of very strange networking problems on her computer, however. Appearantly those networking problems were preventing the connection to the repository from working as well. Imagine my surprise when I tried to check out a module, and the reply I got from the CVSNT service was "I hate you."
Admin
This is actually a sign of very good code. I assume there is another test earlier in the code path for iFile.Exists, so execution should not reach this point if the condition is false. This code is then just a safety net in case the coder missed some case where the first test could be skipped.The only problem is that the comment says that the code wouldn't be there when it means that execution would not reach there.
Admin
You could use a logarithm for the width of the number... (in VB again.)
print string(myWidth - int(log(myNum)/2.30258509299403) - 1, "0") + trim(str(myNum))
Admin
And did you imeadiatly run to your boss and demand more professional software?
Or, did you chuckul for a second or two (possibly calling over your coworkers to chuckle too), and then get on with your work?
Admin
Heh, rounding errors?
Admin
<font size="2"> /*
Is the object's validity not implicit in the asking of the question? If it were not, would we be asking the question? It's a very anthropic situation that is far too complicated to discuss in code comments, please refer to the product documentation for more insight.
This is not a new problem. Heidegger has treated it and the Existentialist approach would be an investigation starting with the (legitimate) question "where lies validitys validness?". However, a more Wittgensteinian (the later Wittgenstein) approach would recognise that this might in fact be a grammatical problem rather than a philosophical one in that by using the noun "validity" we take for granted and posit as real the objective existance of "validness".
However, the authors of the code refute these essentially nihilistic approches, including post-modernistic conceptions of validity, and instead defines the problem as an analytical one. Thus we see that the question IsValid() in fact contains its own truth condition, and the answer is trivially always true. (Gadamer, Warheit und Metode; Heidegger, Zeit und Zein; Wittgenstein, The Blue and The Brown Book, Tractatus Logico-Philosophicus; Russel, Principa Mathematica)
*/</font>
Admin
The success message for CVS is the matching "I love you"....
Admin
Check out a dictionary: both ways are valid!
Admin
But the opposite of love is indifference.
Admin
I've always preferred to preface error messages with "Errah!"
The author of the code in "Logged to Death" should have used something like this.
http://www.thedailywtf.com/forums/53224/ShowPost.aspx
Admin
When I develop software, the first thing I do is to create a debug() function, and use it to toggle the display of internally reported errors. An example function (in PHP)
Function DisplayError($msg)
{
if (!Debug())
return true;
/* display the message by whatever means here /
}
With this, code like this works out OK:
if ($someCondition)
{
/ do something */
}
elseif ($otherCondition)
{
/*other Something */
}
else
{
DisplayError("Function foo(): WTF?!?!? How could this happen?");
}
I have lots of such code in my application - it makes it much easier to identify when changes to the codebase break previous expectations and assumptions!
PS: The real WTF is that captcha doesn't work well on this site!