The Daily WTF

Your Daily Cup of WTF

My Links

Blog Stats

News

Got something that just makes you say "WTF?!?". Use the CONTACT form and submit it to TheDailyWTF!

Archives

Thursday, May 27, 2004 #

færsla

Reader Stefán Jökull Sigurðarson, whose middle name means Glacier (now, how awesome is that!), sent along this chunk of C-code, straight from Iceland.

At first, this block of code made absolutely no sense to me. What can I say? My Icelandic is a bit rusty. But Stefán was nice enough to tell me that "faersla" should really be "færsla" (as C doesn’t allow international characters), which translates to "transaction or a part of a collection". So I hope that clears it up for the rest of you.

While we’re on the subject of C, I’m a firm believer that the single greatest thing to come from C is the International Obfuscated C Code Contest, where you can get a Missle Command Game whose source code looks like a "danger – radiation" symbol or a Flight Simulator shaped like an airplane. But there still is a fine line between writing code for an obfuscation contest and writing code for a business application. And although it may seem like a good idea at the time to use "v7" instead of "IterationHitCount," programmers like myself and Stefán would really appreciate the latter.

posted @ 2:45 PM | Feedback (0)

Wednesday, May 26, 2004 #

Because New() Fails Way Too Much

First and foremost, thanks for the WTF submissions! Please keep 'em coming. They don't have to be code snippets or diagrams, just something technical-related that made you say or think What the F--! And now that I think about it, I'd love to see some crazy Boss Emails and Memos. I had a trove of them saved from the last company I was at, but lost them all. So let's see yours! Just use the Contact Form, and feel free to include a website to link back to.

With that out of the way ... I give you this.

Three points for checking to make sure that the built-in New() construct actually created an instance. But, WTF was the coder thinking by not putting in “If Not TypeOf objNews Is clsNewsObject” code? What happens if the type of objNews changed after checking if it was Nothing?

posted @ 3:21 PM | Feedback (8)

Tuesday, May 25, 2004 #

Who Needs Stored Procedures, anyways?

I'm sure we've all heard, over and over, that inline SQL is generally a bad practice, and that we should use Stored Procedures when possible. But let's be realistic for a minute. Who wants to write a stupid stored procedure for every stupid little simple query needed. Like, for example, this query from an actual, production, report-producin' web page:

See how easy that was? For cryin' out loud, do we really need to write a Stored Procedure for something like that? It's only 156 lines or so. Stored Procedurers are for suckers!


Got a WTF you'd like to share? Just fill out the Contact form and send it in!

posted @ 11:43 AM | Feedback (5)

Monday, May 24, 2004 #

Function Batman()

As a certified Überprogrammer, I get quite annoyed with inexperienced maintenance programmers looking at my code and asking questions that any coder with a clue would instinctually know. Take for example this function:

Perfectly clear to me, and I'm sure every other Überprogrammer out there. But the inexperienced n00bs ... they have to waste my time with questions like WTF does Batman() do? or Does it MANage BATch processes? or It prints out the MANual for the Business Aquisition Team, right? or even Does it invoke Silhouette_Spotlight() to create an instance of The_Dark_Knight?

C'mon people. As if it isn't clearly obvious. BatMan() returns False or a DocumentID, depending on whether or not a record with strFileName exists in the database. Jeeze, what's next, asking what JudyGarland() does?


Got a WTF you'd like to share? Just fill out the Contact form and send it in, along with a website address if you'd like.

posted @ 2:52 PM | Feedback (5)

Friday, May 21, 2004 #

Your Daily Cup of WTF - tblDataTypes

Originally Posted At: http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/17/133406.aspx


An actual table from a production database. The client code uses it (I believe) by opening a recordset to it and extracting the field names. What's puzzling is that the system isn't a database schema tool, or anything like that. Just a plain old boring information system.

What I still can't figure out ... why are the columns not named intInt, and dtmDatetime :-)?

posted @ 1:46 PM | Feedback (0)

Thursday, May 20, 2004 #

Your Daily Cup of WTF - tblState

Originally Posted At: http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/18/134106.aspx


Naturally, all tables referencing tblState link with a column “intStateID”

Now, I don't know about you, I think you'd be a fool to implement this any other way. Think about it, what happens if a state descides to change it's name and abbreviation ... and the database you moved to when this happens does support update triggers? Can you really afford to take that risk? I didn't think so!

posted @ 2:23 PM | Feedback (0)

Tuesday, May 18, 2004 #

Your Daily Cup of WTF - tblStaffDirectory

Originally Posted At: http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/20/136018.aspx


I suspect this one may be a bit less common than tblState ...

Used on an in-production, web-based staff directory of 600 or so, the idea behind tblStaffDirectory is expandability. By putting everything in one table, we don't need to worry about ever having to modify the database structure. Data in this table is stored in the following manner:

ID intID strTable strField strValue
1 1 Staff StaffID 1
2 1 Staff First Name John
3 1 Staff Location ID 4
4 4 Locations Location ID 4
5 4 Locations City Anytown

Creative, eh? While queries to retrieve the data in a useful manner may be a bit complicated (120 lines and 38 JOINS to get the equivilant of “SELECT * FROM Staff“), it's a heck of a lot better than the alternative (changing the table structures). Besides, I don't think users mind waiting 5-10 seconds for the page to load. I challenge anyone to come up with a better implementation than this.

posted @ 11:00 AM | Feedback (0)

Monday, May 17, 2004 #

Your Daily Cup of WTF - IsTrue()

Originally Posted At: http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/21/136890.aspx


Yesterday, we learned that sarcasm is officially dead. Oy. So today, let me disclaim by saying that I am not actually advocating this as a good practice. Just trying to toss in a little humor. And also, let me applogize already for having a weak example today, been too busy to dig for some real gems. And with out further ado, your Daily Cup of WTF:


Now I for one can't seem to fathom why the folks at Microsoft that engineered the framework did not think to include this as a core function. Honestly, how else are you supposed to know if an expression is true or false. See how ambiguous and confusing this is:

If myDocument.IsActive Then DoStuff()

I'm completely lost. WTF does that line of code do? Now lets see how it looks when we employ best practices and the the IsTrue function:

If IsTrue( objInstanceOfDocument.blnDocumentPropertyIsActive ) Then fn_DoStuff()

Crystal. Clarity.


Some more ado ... Fellow blogger brady gaster suggested I start a separate blog where we all submit ideas. I did the first step, and registered TheDailyWTF.com. Any ideas on a good way to configure .TEXT for it?

posted @ 2:36 PM | Feedback (0)