Recent Articles

Feb 2005

Count Rowula

by in Feature Articles on

I've been hanging on to this snippet of code (from Brett J.) for quite a while now, mostly because I didn't think it was real. I mean, really, no professional programmer would ever retrieve an entire table and loop through each row, just to get a row count ... right? A few weeks later, I got a similar submission from Sanket. It feel to the bottom of the stack and I never got around to posting it. But just recently, Enigma sent in yet another example of this technique. It had to be posted.

So, here it is: Three different developers. Three different languages. One combined example.


Implements ISwissArmyKnife

by in Feature Articles on

I have yet to find someone who doesn't love Swiss Army Knifes: you know, those multi-function thingies with a few blades, a screwdriver, scissors, and a pepper grinder? Well, as surprising as this may be, the concept behind this Macgyver-saving-tool doesn't work well when applied to software development. But you gotta give Rick Harris' colleague some credit for trying ...


Trust me, It's Easier This Way

by in Feature Articles on

Eric Balsa sent in some code that exemplifies his former colleagues' approach to "simplistic design." If it's not immediately apparent why this method makes anything easier ... understand that this is actually a PHP include file. Make sense now?


Where's WTF?

by in Feature Articles on

But not as in Where's Waldo ... those are seriously tough. I'm talking about the one in the back of the Highlights magazine that all dentists' and doctors' offices seem to have. You know, where it's a illustration of a cat in a tree, and you're supposed to find the cat? I love those ... you get such a feeling of accomplishment.

But anyway, let's see if you can find the WTF in todays VB6 code from Tim C ...


Looking for a Date

by in Feature Articles on

Hope you're all enjoying Presidents Day; I have nothing presidential to post to mark this occasion, so I hope this will do ...

A common requirement in programming is determining the number of days in a given month. To do this, many of us will try to utilize date/time functionality built-into the language. Others will recite the "Thirty Days Hath September" poem and hard-code the days, braving future compatibility problems (just ask a vet how much of a pain the Julian Migration was back in 45). And then there are the few who just can't seem to find a good way of doing this, and come up with their own way. Like Michael Knight's colleague, who'll just keep picking a number until it works ...


Basic Complexity

by in Feature Articles on

One the criticisms and praises I often hear about Visual Basic (my language of choice) is that it makes things very easy to do. You'd be surprised, though: not all VB developers go the "easy" route to do simple tasks, such as copying files. I think most of us would use the FileCopy method. Or the FileSystemObject.CopyFile method. Or even come close the WTF-line by issuing a "copy" command with the Shell method. But for those really dedicated (such as a certain Angry DBA's colleague), they'll find yet another way of accomplishing what they need to do ...


Playing Catch

by in Feature Articles on

This has to be one of the more humorous examples I've seen in a while. The anonymous submitter discovered it while trying to find the source of a rather peculiar bug. Apparently, the exception information wasn't providing enough information about the source of the error. I can't say I'm too surprised ...


            

Unconventional Naming

by in Feature Articles on

I haven't posted anything from my personal collection of WTF in quite a while, so here's something that I came across a little while back. It's (naturally) from a VBScript ASP page developed by some folks who just didn't quite understand the proper way of naming (or, for that matter, using) variables. I think this snippet (from a validation routine) speaks for itself ...


Irregular Expression

by in Feature Articles on

I haven't posted a "WTF" Regular Expression before today because RegEx's are a fairly complex animal. Well, that and I haven't gotten a submission for one. They're incredibly useful tools for parsing and validation, but I think most (including myself) are glad that there are places like RegExLib.com around to save us from the intricacies of lazy quantifiers, backtracking, and lookbehinds.

There are definitely a few out there who will brave the trenches and roll their own expression. After looking at Matt Brown's colleague's 347-character-long, partially-working "mm/dd/yyyy" date validator (used, no less in a language with built in support for date validation), it's pretty clear that not everyone belongs on the front line ...


De-evolutional Theory

by in Feature Articles on

First and foremost, please take a few seconds to vote for The Daily WTF logo. No login or anything required, just click on your favorite choice. Now back to the regularly scheduled program ...

It can be quite excitingto glimpse at the change history of a method and see how it has evolved over time. Well exciting is probably too strong of a word for most of you; perhaps "boring," "tedious," or "the worst-possible-way-I-can-think-of-spending-my-free-time" is a more apt description. No less, I think this example from Nathan Ratcliff provides a unique glimpse of the ... de-evolution ... of the ufTrimZeros() T-SQL function with its three failed attempts at trimming zeros. Hopefully 1.11 should be the only number ever needed ....


IsInteger() ... really?

by in Feature Articles on

Oy. What was Chad thinking, going and referencing "/global/lib/numericFunctions.php"? Sure, it may *seem* like there's some helpful methods in there, epsecially with names like "RoundUp()", "ExtractNumber()" and so on. And yes, it seems logical enough to commonly used methods in some sort of library. But what happens when a simple sounding function, like IsInteger(), doesn't actually do what it says?


Access Denied

by in Feature Articles on

With today's example, I'm not really sure today how I should spend these few introduction sentences. I mean, I could demand that we allow the author of this Access inline function only use an Etch-A-Sketch, two plastic cups, and some playdough for all future development. I could console the victim, Jason Law, who actually to deals with the aftermath of this reckless "programmer." Or I could even offer a challenge to see if anyone can actually figure out what this monstrosity does.

Instead though, I'll just humbly point out that I went to the trouble of formatting it (with three failed attempts) for your reading displeasure. Yes, that's right, it was initially a single line of code.


Real Consultants Don't Use Loops

by in Feature Articles on

Loops. They're so ... well ... loopular. I mean, come on, do we really need them? Do we? If you think about it, they're nothing but crutches for the weak. Kinda like case statements or switch blocks. No, us highly-paid consultants don't need any of that. In fact, here's a perfect example of how to write PL/SQL. It's from the "professional services" division of a company that shall remain nameless. Jeff Atwood knows what good code is like.


But I'm Using using

by in Feature Articles on

There's nothing better than being called up at 4:30 in the morning to solve a production crisis. Well, aside from sleeping. Or baking. Or antique furniture restoration. But nonetheless, Alexander Shirshov was called in to help increase the SQL Server connection pool size. It would seem the backend to their retail inventory system kept generating error messages:

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.


Yet Another "Hex To Ascii"

by in Feature Articles on

So who would have thought that Hexadecimal to ASCII encoding methods would turn into an entire series. So here is the fourth (I think) installment of ever-so-illusive algorithm from A. C. Hynes, implemented yet again in C:


For-Loop Illogic

by in Feature Articles on

I've received several submissions just like this but have always avoided posting them because they seemed too short. Well, that, and I couldn't think of anything to say about this sort of (il)logic. I still got nothing, but fortunately Telek added a little more background:

I found this in source code that one of our customers sent us. They were complaining that when processing large incoming buffers our device ran too slow. I took a quick look through their code and it was no wonder why it was slow. However this one function, run on every character of the incoming/outgoing buffer, deserved special mention.


Logical Tiers? That Makes No Sense!

by in Feature Articles on

Some developers just don't believe in "standards." I should know, I used to work with some of them. They had their own way of doing things, from reinventing the database to changing the web paradigm. I always found it ironic that these folks have a pretty good knowledge of the tools, but could never seem to figure out how to use 'em. Like Chris' predecessor, who seems to have done the equivalent of tightening screws with a voltammeter.

Ok, so I had to port over an ASP app to Coldfusion MX. It was a simple set of search pages so I didn't think it would take too long. Problem was, I couldn't find anywhere in the code where the HTML for one of the select boxes was. Silly me, I should have checked inside the SQL Server stored procedure first! And of course, this is just the tip of iceberg on this site. There were stored procedures that were used to build the actual HTML for the dynamic navigation as well.


Can you ping me now? Good!

by in Feature Articles on

Now I suppose today's post isn't too technical. But, it made me chuckle. And, it's from Scott C. Reynolds. So, here goes ...

I've said before that Verizon is like "Joe's House O' Telecom" with a large customer base.  Today proves it.  Our T1 in our New York office went down and we lost connectivity, and our Florida office was basically screwed for the afternoon.  Verizon reported that they were having a router problem "a few hops away"....well, when they still hadn't solved it 6 hours later, we decided to run a test:


Robust Error Handling

by in Feature Articles on

Just as treehouses usually don't need reinforcing steel girders, a 12-tier approach for a simple application is usually a bit more than is generally needed. But that doesn't stop Roy's colleague. No, she'll be the first to rent an earthmover to help build a sandcastle. But just try to imagine how fun the error handling would get when a function moves beyond the complexity of always returning True.