- 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
Whoa! This is some neat code. :)
Admin
Isn't it ironic that an article, beginning with a statement about "typing", has this typographical error? ... change about how we write ode:
Admin
You may just write code. When some of us do it, it's even an ode ;-)
Admin
The Real WTF is that this site crashed for a couple of minutes just before this new article appeared. Could this be the repeated hammering of F5 by the fisters?
captcha = dreadlocks
Admin
"to their ay of doing things"
Making an ode or an ay? ;-)
Admin
Admin
Well, the biggest WTF is that the code is in Java for sure... And, he clearly uses the exception to get a stack trace... however, IIRC stack trace is initialized upon construction, not when the throwable is thrown.
Admin
Since when did .net have the final keyword?
craaazy indeed!
Admin
Yeah, as the author says, it's just his "ay" of doing it.
CAPTCHA: burned, haha
Admin
An Ode! Aye Captain! Arrrr
Admin
If the error was truly fatal and there was no point in continuing the execution, he should have thrown an Error.
To get the stack trace in logs, he could have used
Admin
For what the code is supposed to do (in the eyes of the original coder) it is fairly concise. That's what a WTF is all about - well written code to do the exactly wrong thing!
Admin
Let us not overlook that he creates a completely empty Exception ---- and then logs it, as if it had some useful information......
Admin
An Ode to the Ay of Certain Developers:
Forsooth! And how doth the keyboard clack As when, among twin perils of unnecessary loops and strange Inner Platforms, Bestride the angry waters of unfamiliar syntax and new paradigms Doth the Certain Developer lament: alas and alack! My brain hurteth so: ay ay ay This mountain, this Learning Curve, I durst not climb.
But wherein his refuge? Of what dost thou speak?
I speak of the inevitable temptation, to wit: As Alexander crossed the Hellespont, As Odysseus braved maelstrom, Verily as Hercules confronted the Hydra, So our hero confronts the Language Beast, And vanquishes the angry unknown, be it syntax or context, With an onslaught, truly a fusillade: the Wrapper of our Discontent, That the Language may, to his will be bent.
Admin
AFAIR exceptions on Java 1.0 and 1.1 have to be thrown to get the stacktrace filled in. If the code is older, this might be a correct attempt to get the assert-function working.
Regards, Lothar
Admin
If you want a stack trace in .NET, call Environment.StackTrace.
Admin
I once wrote:
/**
... it worked every time...
Admin
Beautiful wipes tear from his eye
Admin
Oh boy it's a computer geek AND a classics geek! What an awesome combination. Kudos to you!
Admin
I just had to format that one and post it on our geek wall. Here's a screenshot of it in Word Print Preview (sorry, no tables involved).
[image]
Addendum (2007-06-11 14:33): I added in "the" and added in a break after the comma in "...unknown, be it". I then printed out the new copy and replaced it on the wall.
Admin
I am duly honored.
BTW, I made a small typo: there should be a "the" in front of "maelstrom".
Admin
I fail to see the wtf, here. I used to write code exactly like this a few years ago, as it was the only know way to get a stack frame in Java.
The real wtf seem to be the speed by which this site is going down the tube (even renaming from "what the fuck" to "worse than failure" made me thin WTF...)
Admin
Admin
Worst. Haiku. Ever.
Admin
This is exactly the thing I try to guard against when teaching people to be "pythonic" when writing Python code, and what I am trying to get across in my last blog post Dynamic Hell in Python Names. Moving between languages inevitably drags along both bad and good ideas that all become bad in the new environment.
Admin
You, sir, have earned the title of Poet Laureate for WorseThanFailure.com. I bow to your poetry skillz.
Admin
That's almost the same as the error handling at a previous job:
Admin
The REAL WTF is that you think the function name is an accurate description of what happens.
Admin
I wouldn't really call this a WTF, it's just an example of someone who doesn't understand Exceptions.
Admin
Which game might it have been that ruined the "c" and "w" keys on Alex' keyboard? ;o)
BTW, it's Java, not C#, and another minor WTF lurks in the disregard of proper Java naming conventions, i.e. the notation of the function name (all caps...).
Said developer is either an AOL user or a Csharpie all right... ;o))
Admin
You must remember this: A catch is just a catch; a try is just a try. The fundamental things apply As platforms go by.
Admin
WTF does Assert do anyway? Really.
Does it stop program execution if true? Does it Assert that the value is indeed the value or does it just write the value to a debug window. VB programmers everywhere need to know.
I mean it's not like debuggers are usefully anyway.... I mean really I could manually evaulate all the code in my head in context and find the problem.. right?
Admin
Technically, since C doesn't have booleans, assert(false) makes monkeys fly out of your butt. Sideways.
assert(0), on the other hand, prints a message to stderr (which this function doesn't do), and calls abort() to terminate without standard cleanup (which this code also doesn't do). Unless NDEBUG is defined at the moment <assert.h> is included, in which case nothing happens.
Admin
what good is assert? It's bloody usefull to have when working with non-programming staff, like say, artists.
Telling an artist that "no, 36 is NOT a power of two, but 32 is" is just pointless, because they'll STILL make those textures in incorrect sizes. Put an assert on the build they use for testing thier art, or even on the conversion tools and they'll soon get the message.
Making apps or tool-apps handle incorrect things like that by chopping of bits to the nearest ^2 just makes them lazy and they'll bitch and moan how the code screws thier work up. A controlled crash landing using a custom assert macro however, will make them fix it straight away, or atleast after they've run crying to your desk.
The same thing goes for live game code...screw handling incorrect bone names gracefully. If the game has used a bone called "focus_point" for the last six months, I'm not bloody changing the code because of a typo or making the test build just focuson on the origin. Assert straight away, so they can fix thier own error...after coming to your desk demanding to know why you've broken thier art.
Admin
Whats even more of a WTF is that in C# there is: Debug.Assert(expression); and in Java: assert expression; Or is it somehow different? Am I missing something?
Admin
The real WTF is that assert is used in that project too. TIMTOWTDI I guess.
Admin
Is the WTF supposed to be that he was so stubborn he refused to give up the assert method of dealing with errors? Because if so, he isn't the only one so stubborn. Java (as of 1.4 I believe) now supports asserts. Granted it doesn't perform a System.exit but instead throws an AssertionError, though than can be problematic when certain people write:
And no, I didn't forget the ellipses in the catch block. I have seen that without anything in there (ok, maybe there was a comment or two).
Admin
ROFL... One of the best WTFs ever!
Admin
Technically, C has booleans - they're called _Bool (also bool if you #include <stdbool.h>). And that same header includes macros for true and false. Section 7.16 of the current C standard.
Admin
I wish I has as much free time as you
Admin
Saw a great t-shirt this weekend:
Haikus can be fun. Sometimes they do not make sense. Refridgerator.
Admin
int false = 1; assert(false);
I see no problem.
actually, something happens - the token sequence ((void)0) is inserted into the code. Exactly that token sequence - it can't be ((void)(0)), ((void)1), or anything else that would be equivalent, it has to be exactly ((void)0).
Admin
I gues I am lucky or unfortunate because I never really got to do any real C programming or Java for that matter. So for just laughs we can say Assert is the flip side of On Error Resume Next even though it isn't actually in principal it something like that...
typedef int BOOL;
#define FALSE 0 #define TRUE 1 #define NULL 0 //OMG WTF 0 as in 0x0000
Admin
#define MAYBE -1
yes it's now TriState lmao
Admin
Admin
An exception is used to detect and handle dynamic error conditions arising from the data or the environment - e.g. an over-length string, or running out of file space.
An assertion is not supposed to be used for this: it's used to detect and abort if a condition occurs which can never happen if the logic of the program is correct - e.g. an array is passed as a parameter and its length appears to be negative. You can turn off assertions in a correctly written program, and the behaviour of the program will be completely unchanged - which is obviously not the case for exceptions. C exceptions are great: scatter them liberally to test the invariants and preconditions in your code, and a lot of bugs surface with very little effort. I generally try to make some sort of equivalent in languages which don't directly support assertions, and often bodging something up with an exception is the nearest you can get.
Admin
D'oh. My bad, been forced to use an out-of-date compiler for a while now, and apparently it's killing off sections of my brain.
Admin
I was glossing. Yes, it sticks in something to make sure the compilation doesn't issue spurious warnings. At runtime, nothing happens.
Admin
My eyes... the goggles do nothing!!!