Don't worry, it always does that
by in Feature Articles on 2004-11-30In a real rush today, so hopefully the comments will add some fun commentary. Here's the screenshot, from Tristan Harmer ...
In a real rush today, so hopefully the comments will add some fun commentary. Here's the screenshot, from Tristan Harmer ...
As it would turn out, the earlier post today was not real. To be fair to me, the top of the post read "I found this in production code ..." but at the way bottom, it was "i'm making this up". But still, my bad! So, here's a few short ones to start off your week ...
From Anonymous:
Andrew Cattle found this in a legacy system. I wonder what would have taken longer: this or actually porting the code from VB to C++?
While working for one of the top-5 pharmaceutical companies, Daniel Drucker was handed some legacy Perl 4 stuff and told to "patch it up". Surprise, surprise, the code had some rather ... unique ... ways of doing things. Not to be out done by the guy who invented functions, the coder came up with his own way to create indexed groups of strings.
$roles = "usersuper useradministratordenied";
$roles_offsets = "000004014027";
Some readers have reported trouble with bloglines and other RSS readers. Check the URL of the feed. Please use http://thedailywtf.com/rss.aspx to keep a feed similar to the one before moving to the new site. If you use another url (such as http://thedailywtf.com/rss.aspx?ForumID=12&Mode=0), then you will get a feed that reorders posts whenever a new comment is posting. Bloglines (for whatever reason), is using the latter URL. Hopefully, they'll update it.
So if you inherited code like this (as Luke Frost did), would you really want to look in the database?
Here's a good Friday post from Derick Bailey:
I inherited a glorious WTF in a 426 line VB6 validation routine that was inherited by many before me and rarely, if ever, modified from GWBasic, through VB1 and all the way up to VB6 over the last 10 years. Among the many jewels of repetitious redundancy in code, I found this wonderful chunk that I like to call “When If-Then Attacks”. After refactoring the code for vb.net, the 426 lines came down to a manageable 230 lines of code ... it works just fine, now, but I still have no clue as to the actual logic of the validation.
Some folks have some rather strange superstitions when it comes to programming. Take for example Maik Schreiber's colleague. He believes that directly comparing a string variable (xmlTagName) to a string literal (“sub_name“) will make your program run as slow as cold molasses. So, to avoid this, he built a data structure with all of the possible names and, for every xml tag in the document, searched through this data structure to find the tag name, and did the appropriate action ...
Every once in a while, I like to switch gears and post tech support stories. After all, how many among us didn't start out doing something technician related, unable to find a programming job as a seventeen year old “expert“? Well, here's something from Seth Ness' tech support days ...
An end-user called the tech suport center where I worked, and said that he'd gotten a 5.25" disk stuck in drive B: on his PC.
There was a time when I was a C/C++ zealot, scoffing at those using anything else. A little while before .NET rolled out, I finally grasped the concept of “cost effective development“ and transitioned into being a VB advocate. One thing I've always missed in both VB and C#, however, was the ability to define macros. After looking at this, I don't know if I'll admit that any more ...
Adam's colleague revives a classic way of ensuring that no one is able to use your source code to figure out how to connect to the database. That is, so long as they don't have the Little Orphan Annie Secret ASCII Decoder Ring ...
Don't you hate it when you've finally sunk into the supreme, Über-komfortable position on the couch, only to have a rotisserie cooker infomercial come on and the remote control mock you from an unreachable distance? I'm sure, among us, there have been many solutions to this dilemma, from using a shoelace lasso to snag a broom to press the buttons on the TV, to jamming keys in the electric socket to cause a short, throw a breaker, and make the audience finally stop yelling "Set It and Forget It!"
Now that's perfectly rational and understandable. But, I can never picture myself saying:
Those of us not accustomed to arduous change control policies and procedures put in place by many large institutions are likely unfamiliar with the second part of the “if it ain't broken, don't fix it“ motto. It's long, but it goes something like “ ... and if it it's only broken a little, say it's a feature ... and if it's broken a lot but can be fixed easily, pray that the code review overlords will not smite you for requesting such a puny change ... “
Apparently, Geert wasn't familiar with the “ ... and if it's an important feature that hasn't worked for quite a while ... “ part. He was searching for a bug in a Delphi module, and discovered a partial cause with some really poor error handling ...
One thing I really love about this blog is that it's a wonderful learning experience. I think too many of us rely on things like “manuals,“ “books,“ and even “best practices“ to guide our programming and software development. For example, if I was developing an application in Visual Basic 6 and needed to resize an array, I would just ReDim it. I'll even go so far as to say that I couldn't think of a different way to handle that situation. But not Matt Hawley's colleague. I think he's just born to think out of the box.
Andy Brummer sent in this story ...
One day I was assigned a defect for an online helpdesk submission application that I had ported from classic ASP and VB to ASP.Net and C#. Everything appeared to be working fine, except when the tester entered phone numbers in the comment field the line always came out with this strange riddle:
Generally, high level languages have built-in date and time formatting, allowing you to present dates and times in virtually any manner you'd like. On the occasions that a language doesn't have such built-in support, it's fairly easy to write a method to do it for you. Going this route, as Jani's colleague did, is probably not the best way to go ...
Database Administrators (especially Oracle) are the least appreciated members of the IT Community. Sure, it may seem like it's easy work. After all, how hard could it be to ignore the first three requests for help, reject the next two on grounds that the request form had clerical errors, make up a technical rejection reason (“partial index hash scan may cause the secondary file store to incorrectly lock“) for the next, and then, after another few days, finally fulfill the request?
It's not easy at all, especially making up technical reasons: there's only a finite number of database terms that will fly over the average developer's head! So with this in mind, here are two stories that I truly hope will inspire you to give you DBA a big hug.
Rocco Caputo pointed me to a Perl job opportunity the other day that was pretty, umm, demanding. I always wondered ... how could anyone possibly write that much code in one day? Apparently, your best bet is to go the whole IHBLRIA route and rewrite things like the lc() function, as Edy's colleague demonstrates:
sub utl {
$i = $_[0];
$i =~ s#A#a#gsi;
$i =~ s#B#b#gsi;
$i =~ s#C#c#gsi;
$i =~ s#D#d#gsi;
$i =~ s#E#e#gsi;
$i =~ s#F#f#gsi;
$i =~ s#G#g#gsi;
$i =~ s#H#h#gsi;
$i =~ s#I#i#gsi;
$i =~ s#J#j#gsi;
$i =~ s#K#k#gsi;
$i =~ s#L#l#gsi;
$i =~ s#M#m#gsi;
$i =~ s#N#n#gsi;
$i =~ s#O#o#gsi;
$i =~ s#P#p#gsi;
$i =~ s#Q#q#gsi;
$i =~ s#R#r#gsi;
$i =~ s#S#s#gsi;
$i =~ s#T#t#gsi;
$i =~ s#U#u#gsi;
$i =~ s#V#v#gsi;
$i =~ s#W#w#gsi;
$i =~ s#X#x#gsi;
$i =~ s#Y#y#gsi;
$i =~ s#Z#z#gsi;
return $i;
}
... well, I'll let you be the judge of that. Atanas Korchev provides us with this compiler error from a project that I'm a bit afraid of seeing. As it would seem, 70 is the number of arguments in this case ...
Julio César Carrascal Urquijo challenges us to spot the number of ... irregularities ... in this ... interesting ... implementation of a sequential id (identifier) generator in T-SQL. My only guess is that the developer here came from the elite world of Oracle, where even the simplest things like sequences are painfully difficult.
Scott C. Reynolds was looking for a strong C# developer a while back. He was kind enough to share the tale of one of the many, many unqualified recruits (who we'll call “J“) with us.
The job description in the ad is pretty explicit about the level of experience required in .NET, C#, SQL, and app development in general. We get "J" through a headhunter. First, excerpts from the questionnaire the headhunter gave him, then forwarded to us: (spelling and grammar his...)