Recent Articles

Feb 2007

What Could Possibly Be Worse Than Failure?

by in Alex's Soapbox on

Earlier this week, I changed the name of the site to Worse Than Failure. A lot of readers weren’t too happy with the new name and many of you wondered why, of all names, did I choose Worse Than Failure. After all, what could possibly be worse than failure? In lieu of telling a specific story of failure today, I’d like to share my insights as to why there are – and will continue to be – so many spectacular WTFs (as in, for old time’s sake, What-The-F*s) in our industry, and why so many of them are, in fact, worse than failure.

In the almost-three years that I’ve been writing this blog, I have seen some of the most obscene perversions in information technology ever created. Heck, we all have. While quite a number of these disasters can be blamed on amateurish incompetence, so many defy all explanation. It’s as if highly-capable, incredibly-intelligent, and good-natured software engineers got together and said, "Let’s build the worst software ever created!"


A Really Really Phat Pipe

by in Error'd on

I don't know which is more impressive; Tyler M's phat pipe (I promise to never say "phat pipe" again), or that he finally found a site that could serve files fast enough to justify his huge bandwidth bills.


The Black Box of Or

by in CodeSOD on

Tony has a problem. He has been charged with turning a stack of Python code into nice, shiny PHP. Now, I'm not one to trust a language that makes such a big deal out of white-space but having a style imposed on developers does have it's benefits. For one, the code is supposed to be more easily groked precisely because the reader only has one style to parse.

Still, it's been no picnic for Tony.

I didn't write the original non-documented, barely-commented code. I don't even know who did, so I employ a strategy of examining this code as well as its input and output. Once that starts making sense, I write a PHP function that does at least that and sometimes more. I'd like to share one exciting bit of code I came across during this process.

Hallway ERP

by in Feature Articles on

In the early 80s, the server room at MegaCorp (as we'll call them) was cutting edge. Humming along to A Flock of Seagulls and occasionally taking breaks to solve Rubik's cubes, the engineers installed servers, networking equipment, and a main air conditioning unit. Their infrastructure was among the best in the business.

Sadly, some 25 years later in 2005, the server room wasn't doing so great. Winston S. witnessed firsthand the first cracks as they began appearing (literally).


Enough String to Hang Yourself

by in CodeSOD on

Many people (especially, with articles like this) miss the distinction between the writer and the written-up. One of the hard things --- as an editor and as a coder --- is to not just blurt out all the answers: that ruins the fun for everyone at the sake of being only slightly less incomplete. When there is a "challenge" to re-write something, it's just for fun and we should probably refrain from making it personal.

That being said, I've got the hint that many of you like string functions. Here's one John found. Yes, it's C++; and yes, they're working with char*. I'll assume you can figure out why it's called strcmpi.


Impossible, Impractical, and Too Expensive

by in Feature Articles on

A. Thompson didn’t realize it at the time, but he had taken a job as a Third-Class Programmer. For those unfamiliar with this class, those in it are considered to be even lower than Contractors (i.e., the second-class). They have far less responsibilities, no latitude to make any decision at any level, and always get assigned the “dirty work.” In fact, some even consider it an act of charity to call these poor folks “programmers” at all.

A.’s new job was at a company I’ll call Herald Media Services. At the time, they were the largest (in fact, one of the only) suppliers of cable television listing data. Although Herald did all sorts of interesting things with this information, A’s department focused entirely on “new headend setup.” They didn’t do any of the fun stuff like configuring headend equipment; they simply had to generate a pipe-delimited information file containing locale-specific channel information. And as Third-Class Programmers, they had to generate this file by hand.


I Guess I'll Stay In

by in Error'd on

Wesley D. was glad he checked the weather before going out for a cup of coffee. "Partially cloudy downtown with some scattered showers. We're seeing high 60s, low 70s throughout most of the area. If you're up in Alpine, we'll be seeing temperatures around three times the boiling point of water, so you may want to stay in to prevent your flesh from completely melting off your body."


Announcement: Free Sticker Week!

by in Feature Articles on

The bad news is that, judging by recent comments, everyone has stopped reading since I changed our name to "Worse Than Failure." The good news is that I’m giving out free stickers to the dozen or so of you that decided to stick around! Simply be one of the first hundred to fill out this form and I'll mail you a sticker for free. Don’t worry if you miss today’s; I'll be giving out a hundred each day (UPDATE: Starting at Noon, EST) through Friday this week. Enjoy.

Well, that was fun! A lucky 668 of you managed to fill out the form and will be sent a free sticker. As for everyone else, you can still get one, you'll just have to cover the postage. Details Here.


The End of Hex as We Know It

by in CodeSOD on

The abstractions we build in computer science are meant to sweep away painful implementation details for any program, to make them someone else's problem. On real systems it's not always that simple. In the real world, it is sometimes necessary to get down in the muck and reinvent conventions in order to reinforce the foundations of a particular project.

Take, for instance, the an example sent in by Corey.

I work on this fantastic system, where a particular DB table needs to store some 25 flags which are part of configuration data. Instead of using named bit fields, these flags are stored as "machine-hex" strings representing the bitmap. Machine-hex is like hex, except that it is [read] little-endian and ':', ';', '<', '=', '>', and '?' denote the digits after 9. Thus the string '4<1>:0' stores the flags 0000 1010 1110 0001 1100 0100.


Announcement: Website.RenameTo(“Worse Than Failure”)

by in Feature Articles on

Final Update: thankfully this is all nothing but an embarrassing memory.

As you can probably tell by now, The Daily WTF is now named Worse Than Failure. Don’t worry – nothing else is changing – it’s still the same ole’ WTF.


Unsolved Murder

by in Error'd on

Poor old Mark. Good guy. Kept to himself. Showed up day in, day out, writing documentation for SQL Server 2005 until one day when Sterling L. broke into his office, bludgeoned him to death with his own keyboard, and disappeared.  Mark was committed to his company, though, and in his dying moments barely managed to finish typing "Service Pack 1 as part of the installation."


When A Problem Comes Along, You Must skipit

by in CodeSOD on

An anonymous snippet comes from the land of Visual Basic, where people continue to prove on a daily basis that simplicity of syntax offers no protection against screw-ups:

Having recently started a new programming job, I've quickly discovered what most of the day-to-day grind entails: Deciphering and cleaning poorly written Visual Basic code before actually being able to perform my assigned work. Our codebase has plenty of the usual suspects: Variables with meaningless names like "AA" and "bbb", thousand-line functions (which approach VB's built-in limits), no-ops, unreachable code, gobs of copy-and-pasted code, and a few instances of this little construct (irrelevant code removed):

If {condition} Then

        ' ...code here

        Goto skipIt

End If

' ...more code here

skipIt:


GRG and the Mystery of the High Test Scores

by in Feature Articles on

One thing I miss about working at a large organization is watching the blame game get played out. It always amazed me how much more effort went into explaining why a problem wasn’t someone’s fault (and most certainly not his responsibility to solve) than actually solving the problem itself. The larger the issue got and the more experienced players that got involved, the chance of actually solving the problem became nil.

At a certain government agency -- whom I'll call them the National Intelligence Bureau -- several different agents had been involved in a few “high profile” incidents of the international variety. This resulted in a public outcry and strict orders from the top to rectify the problem. As an IT contractor working for the NIB, G.R.G. had a chance to watch the whole thing play out from the inside.


Removing Spaces, the Easy Way

by in CodeSOD on

There are tons of functions in so-called "standard" libraries, but sometimes the function you want just isn't there. Luckily, string functions are so simple to write that anyone can do it!

Submitted for your consideration, an example from Randy, who says, "I think the design kind of speaks for itself." The following code demonstrates how to get rid of unwanted spaces.


Please Retype The Bible

by in Error'd on

I know, I know, the real WTF is TheDailyWTF.com's CAPTCHA software. Har har. Just be glad we don't use patterns as long as this one that B. P. found.


Immaculate Backup

by in Feature Articles on

Murphy's Law 198§44: the more complete a backup/recovery solution becomes, the less likely it is to ever be used.

With nearly half a century of experience using computers to run their business, Chris M's company knew that law all too well. Ever since that fateful Wednesday -- still known throughout the company as The Crash of ‘68 -- they swore, Never Again. And forty years later, they’ve kept their promise.


Taking the U out of UUID

by in CodeSOD on

Paul N, spotted this ColdFusion code in a third-party shopping cart system he'd been tasked with modifying (to make it usable):

 


Roll Your Own Clustered Index

by in Feature Articles on

It was a slow day for Levi C. His company had an excellent staff and meticulous development and testing procedures, so calls for maintenance were rare. He was beginning to feel like the Maytag repairman of maintenance programmers. Fortunately, he was delighted to get a call from one of his favorite clients.

"Hi Levi, if you have any spare time, could you check out this report that's running slow? It's for a system we had developed by another company. It's really no big deal, just if you have a second..." Bored and eager to help, he got all the information he could about the issue. He tried running the report for the previous month, and it was indeed running slow. He ran the report again for the past two months, and it timed out.


A Real Brazil Nut

by in CodeSOD on

Code snippets know no geographic boundaries.

Jose Sobrinho sends us a great abuses of IF statements all the way from Brazil. The best of his "pearls" is a real mind-bender:


Bunker Buster

by in Feature Articles on

“Hope I’m not waking ya up, but we need a huge favor.” It was just past dawn on a Saturday morning, and Jack’s new boss was on the line. “We need you to replace some servers for the portal system.”

Earlier that week, Jack started working as a subcontractor to maintain and “fix up” a certain government agency’s web portal that was used by thousands of branch offices around the country. Jack’s boss, a tech-savvy businessman who had mostly setup the web portal by himself, was training users and demonstrating the product, and noticed they had a serious problem: their system was running ridiculously slow.


I Hope You Brought Your Discount Card

by in Error'd on

Paul D. exposes the cutthroat nature of the grocery industry. One supermarket runs a sale on ground beef, then the store across the street has it even cheaper, and so on. Meijer pulled out all the stops and basically said "screw it, half a million off. What now, jerks?"


Validating Email Addresses

by in CodeSOD on

The format for e-mail addresses is specified in a number of RFCs; it's a pet peeve of mine when people "validate" away perfectly valid addresses, for instance: websites that think all domains end in .com, .net, .edu, or .org; and agents that refuse to transfer mail with a + in the local-part. To that end, I wrote my own regular expression that (I believe) follows the specification, which I'll share below.

First, I'd like to share some code that Igor found, which he considers a masterpiece.


When it's Done

by in Error'd on

Dan F.'s copy of Half-Life 2 will be done uninstalling in 16 days. Valve had originally planned for the uninstaller to work in 10 minutes, but they hit some snags and were forced to delay. By contrast, Duke Nukem Forever will take just over a year to uninstall.


Global Spaces

by in CodeSOD on

Global variables have gotten a bad wrap. Like goto, comefrom, they are often considered harmful. Not everyone thinks action at a distance is spooky.

These days, they are often used as global constants, whether they're written that way or not. For instance, Rachel found the following global variable in some code she inherited.


The Bank Has Spoken!

by in Feature Articles on

Ask any developer at a bank about their deployment process and you'll hear about User Acceptance Testing (UAT). Many of us have felt the sting of code changes working in one or two environments, only to fail when it finally hits QA. Maybe it's just me.

Our anonymous submitter (we'll call him "Steve") felt this sting, too. He'd carefully and methodically developed a module that worked beautifully in the bank's development and test environments, but failed UAT. Testers had discovered a bug in the module that they couldn't reproduce. The official description was that the module caused "weird things" to happen.


Fun with Files

by in CodeSOD on

I love file systems. You can do all sorts of neat tricks, sharing state based on file existence and naming. If it ends in ".tmp", it's not done yet. If it ends in "_hostname", that's who's handling it. I wish I could remember who said that "back in the day, they had transaction safe databases: we called them file systems."

When doing tricks like these, it is important to have four operations: touch, stat, mv, and rm. Recently, Anne found code written by someone that just didn't think the standard functions in C# were up to snuff. Here's an advanced version of FileExists for your perusal.


Lost in Translation

by in Error'd on

Peter T. had, a fantastic time of the entertainment which tried to decipher what required this vigilant case of him. He could calculate towards outside, although, which it checkbox would prevent that different alarm time appears.


Cut, Paste, Destroy

by in Feature Articles on

We live in an advanced age of computing which gives us the convenience of cut, copy, and paste. I'm not being sarcastic; long gone are the days of copying and pasting working only within the scope of one application at a time, but now the sky is the limit! With great power, though, comes great responsibility.

T. B. was working on a system that was being gradually ported to .NET. A lot of progress had been made, but there were still some legacy components. By reading some of the old VB code, you could actually see the learning curve. Early modules had code comparable to crude cave paintings of stick figures throwing spears at boars, while more recently developed modules were more like slightly less crude cave paintings of stick figures throwing spears at boars.


One Step Forward...

by in CodeSOD on

When working with embedded systems, it is sometimes important to do dirty little hacks. There are many ways to call upon the dark magic, though a large number of them are pointer or string tricks, often sacrificing readability and portability for memory or performance. There is a local benefit.

As a contractor, James runs in to his fair share of funny things in firmware. The following code, however, did not make him laugh.


A Case of the MUMPS

by in Feature Articles on

You may not realize it, but the majority of us developers have been living a sheltered professional life. Sure, we’ve got that living disaster of a C++ application and that ridiculous interface between PHP and COBOL written by the boss, but I can assure you, that all pales in comparison to what many, less fortunate programmers have to work with each day. These programmers remain mostly forgotten, toiling away at a dead-end career maintaining ancient information systems whose ridiculously shoddy architecture is surpassed only by the tools used to create it. Bryan H lived in such a world for over two years. Specifically, he worked at a “MUMPS shop.”

With no experience and a three-week old college diploma, Bryan was pretty happy to land his first programming job. He had never heard of the programming language that the company used, but he was assured that he’d receive plenty of training and should have trouble picking it up. And they weren’t joking about “plenty of training.” Bryan’s first three months were spent entirely in a classroom filled with other recent grads, all learning about what the next forty years of their lives had in store: MUMPS, MUMPS, more MUMPS, and, if they were extra lucky, a dash of Visual Basic.


Local Mistakes

by in CodeSOD on

We've talked about localization before. Maybe it's just really hard to remember that some people use symbols differently than you do. Luckily, most modern languages have tools to help us deal with rules we never wanted to know about; in .Net, this all lives in System.Globalization.

Esteban recently came across a good example of how to be sensitive to the way other people use commas and periods.

What often seems to be the most difficult is the decimal separator, especially for the person who wrote this code. I found it during a review to verify that specification changes had been implemented in a lot of old code.


I'll take 94,249 please

by in Error'd on

It's time to add a new series called Error'd and retire a classic (Pop-up Potpourri). Like Pop-up Potpourri, Error'd will feature fun error messages and other visual oddities from the world of IT. But instead of being a monthly feature, Error'd will be published every Monday, Wednesday, and Friday. And as always, don't hesitate to send in your own Error'd screenshots and photos.


Online shopping is great. If you need a large quantity of something, you're likely to have better luck online than in a traditional store. For example, say Danny G. wants to fill his Olympic-sized pool with memory pills - he can simply order 72,489 bottles from Amazon.com (you may not want to click if you're on dial-up). Hopefully he'll qualify for free super saver shipping.


Practice Makes Perfect

by in Feature Articles on

Most of us IT professionals have come to learn just how cautious one must be when upgrading third-party components. Some of us have learned the hard way, first proclaiming, pssh, big deal, it's just Service Pack 3; it couldn't possibly break our application, and then learning that, in fact, Service Pack 3 was a big deal and did break the application. Others are naturally cautious and try to make sure planning, testing, and all those other things are done prior to any upgrades.

Database upgrades can be especially risky. A new version means different query optimization, new language constructs, and, in Oracle's case, the introduction of VARCHAR3 and subsequent deprecation of VARCHAR2. This is why, when Kevin's company decided to upgrade their database from SQL Server 2000 to SQL Server 2005, they put him in charge of formulating a schedule for a six-to-twelve month upgrade plan.


Turn it up to Eleven

by in CodeSOD on

Though it has been described as only a PDP-11 assembler, C stands in a place of honor, surrounded by children, legitimate and illegitimate alike. The reason is very simple: C is not just a PDP-11 assembler. It simplified things by giving us the ternary operator.

At his last job, Frank realized that the magic of cond ? var_t : var_f is that it's not just an operator, it's a fundamental building block of other operators. Forget if then else and temporary variables! Some languages let you write cond && amp; var_t || var_f or statement if condition but that's just syntactic sugar.


Nothing Final

by in CodeSOD on

When C# was created, they decided that C++ was wrong when it came to try-catch. Instead, they took the Java approach and used try-catch-finally. The reason C++ doesn't have this block is because it's unnecessary: since acquisition is initialization, most resources are local. They'll be cleaned up automatically, getting destructor calls as the stack unwinds. In Java and C#, no such luck; thus, finally.

Dave has been cleaning up a lot of C# code recently and found the following, excellent example of finally being used. The real question is, "Finally what?"


The Accidental Hire

by in Feature Articles on

Doghouse Insurance (as we'll call them) was not a pleasant place to work. Despite being a very successful player in their industry, the atmosphere inside Doghouse was filled with a constant, frenzied panic. If Joe Developer didn't delay his upcoming vacation and put in those weekend hours, he might risk the timely delivery of his team's module, which might risk delaying the entire project, which might risk the company's earnings potential, which might risk the collapse of the global economy. And that's just for the Employee Password Change Webpage project; I can't even begin to fathom the overarching devastation that would ensue from a delayed critical project.

To make matters worse, the primary business application that poor souls like Vinny maintained was a complete nightmare. It was developed during the company's "database simplification" era and consisted of hundreds of different "virtual attribute tables" stuffed into four real tables; it was a classic case of The Inner-Platform Effect. But amidst all this gloom and despair was an upbeat fellow named Chris who accidentally became a part of the Doghouse Insurance team.


Rarely Just TRUE or FALSE

by in CodeSOD on

Our friend R.L. writes in with a twist on a common snippet, illustrating an important scientific fact: solutions in life are rarely just TRUE or FALSE ...

 


The Intentional Slowdown

by in Feature Articles on

Despite being a very successful product, the core application maintained by N. L.’s company was completely proprietary, and I mean proprietary. It used its own database; you know, kind of like a normal relational database. Its proprietary database had its own proprietary querying language; you know, kind of like SQL. The application had its own scripting language; you know, kind of like VB. Planning ahead to version 2.0’s big new proprietary features, the company was excited to learn about the possibility of creating a parallel universe so that the physics the company operated under, too, could be proprietary.

It was time for a change. The application was maintenance hell – not just because of confusing, undocumented code, but because finding, training, and keeping staff on was near impossible. The company decided that the application would be ported to .NET and SQL Server. The problem, of course, is that it wouldn’t have that home-built feel. No heart. Just another .NET app, built on standard practices and reliable technologies. No, they had to do something to make the application more unique.


Laying the Foundation for i18n, Brick by Brick

by in CodeSOD on

In Europe, they do things a little bit differently. From what I understand, it boils down to this: they work less and play more; when not working or playing, they drive tiny little cars. Apparently, they all speak different languages too.

Jannik works for a well-known, innovative company somewhere on the continent. Because of the multiple-language problem, his company translates their website into multiple languages. The way their URLs are formed, going to http://www.company.tld/eng/products and http://www.company.tld/deu/products displays the same content, except the former is in English and the latter in ... Deulish?


O Draconian Devil! Oh, Lame Professor!

by in Feature Articles on

Most universities have it rough. If they’re not ivy league, they have a lot of work to do to impress visitors. Sure, Baron von Ivyleague, clad in a Mr. Peanut-esque monocle and tophat, can give students a ride in his flying yacht, but a tenured professor for Uncle Marty’s Community College has to make do with substantially fewer resources.

Your typical college is a sales atmosphere. Campus tours require the guide to embellish a relaxing pond (south-campus swamp area), beautiful performing arts center (cafeteria, chairs removed), and their recently-updated high-tech computing facility (small network of Pentium 200 MMX computers). All it takes, though, is one crazy tenured professor to ruin the sales pitch.


Mr. Memory Leak

by in CodeSOD on

In any industry, there are amazing hacks that are passed down, generation to generation, at trade-shows and conferences. In organizations, these little bits of dirt solidify into idiomatic pearls and paradigms. These sorts of things can't be learned in school.

That's why one of Mac's colleagues took him in and decided to show him the dark secrets of programming. For instance, the best way to clean up variables, is illustrated below.


The Direct Approach

by in Feature Articles on

"Good morning," said Florian, an unshaven twentysomething in need of a haircut, as he approached the security desk outside of the hospital's datacenter. Sporting a tame metal T-shirt and bleached blue-jeans, he could have easily passed as a hippie. Or as a quintessential IT worker from the dot-com-era. The security guard looked up from his newspaper to see what Florian wanted: "I'm here to pick up the PRDSEC08 server."

The data center that Florian stood outside of housed all of the hospital's electronic records. We're talking employee data, payroll data, operations data, and most importantly, patient data. Ever since the passage of that ominous body of patient privacy regulation known as HIPAA, hospitals have been extra careful to ensure that patient records are physically and electronically secure. While the hospital that Florian was at did not create an impregnable fortress accessible only through a series of twenty-ton blast doors, they were very serious about data center security: hardened steel locks, security cameras, card readers, and round-the-clock security personnel monitoring the area.


The Really, Really Long Way

by in CodeSOD on

Jeremiah V. writes to share with us another snippet fact: there is always a longer way to do something, no matter what language is used. In SQL-92 compatible databases, it is a challenge to have a dynamically-generated ORDER BY clause, but there are a number of ways to produce a reasonable implementation. For instance, a quick Google search turns up using a combination of CASE and CONVERT to handle a dynamic ORDER BY statement with different column types.

Jeremiah found the much, much longer version of a solution to this problem. Once he stopped laughing, he notes for us that many, many permutations are missing, save for some of the ORDER BY criteria being treated as a single unit. The CASE and CONVERT functions are avoided in this implementation, but the code size becomes enormous... let's hope they don't add a new column any time soon:


So Bad It Needs An Apology

by in CodeSOD on

My new hero John Connor submitted an epic code snippet.  Let us dissect this in two parts, because it is such a massive SOD that trying to tackle it all at once could cause brain trauma. 


A Fleet of Temps

by in Feature Articles on

Ahh, print publications. Remember those? You'd go to the store, open a magazine, await the avalanche of cards that would fall out, fish one card out of the pile, fill it out, send it in, then camp out by the mailbox awaiting your first issue. Jim T participated in an internship on the IT staff for a popular magazine in Chicago. I know what you're thinking, but no, it's not a nature magazine, though bunnies are involved. Subtlety!

Anyhow, he was tasked with interfacing his magazine's site with a fulfillment house's site, allowing people to subscribe online. Everything was in place, so it couldn't be simpler.


Twelve on a Line

by in CodeSOD on

GRG writes: I've been trying to track down an error in a certain program, used by hundreds of people around the world every day to process gigabytes of very important data. Sometimes it works "fine", other times, not often, only about 0.41% off the time, it goofs up the data, from minor-league (0.22%) to big-time (80%). Apparently the users of this data are not very careful, as the program has had these bugs for at least six years.

It took quite a few days to track down the problem, as the program, for no good reason, resides in about 188 separate FORTRAN and C source files. Finally I found the source of the glitch. Let's see if you can spot the problem too.