Recent Articles

Jul 2022

Poetry in Motion

by in Error'd on

So much cringe here today. Obviously, the first submission below just reeks of professional sycophantry on so many levels. I can't decide which is more offensive, the barefoot butcher or the grotesque attempt to humanize a vogon. To take the edge off, I'll start you out with a very old shaggy dog punchline. The actual setup for this groaner is pretty horrible, though someone on the internet has dutifully compiled the definitive collection of all known variants. Sparing you that misery, I'll cut straight to the chase: Rudolf the Red knows rain, dear. Now you can decide which gag is more worthy: that, or this.

My English vocabulary cannot convey the complexity of my feelings about Beatrix W. who shared a monstrosity, reporting innocently "I was just looking for a book about AppleScript by a Japanese author." Is there a Japanese word for "thank you for this gift but never do it again?"

Classical Solutions

by in CodeSOD on

CSS classes give us the ability to reuse styles in a meaningful way, by defining, well, classes of styling. A common anti-pattern is to misuse classes and define things like "redTextUnderlined" as a CSS class. Best practice is that a CSS class should define the role, not the appearance. So that class might be better named "validationError", for example. A class will frequently bundle together a bunch of stylesheet properties into a single, meaningful name. That's the ideal approach, anyway.

Now, Olivia's predecessor had an… interesting philosophy of how to use CSS classes.

Repetition is an Echo

by in CodeSOD on

Annie works in a bioinformatics department. There's a lot of internally developed code, and the quality is… special. But it's also got features that are on their critical path of doing their jobs.

One example is that, based on one input form, the next input form needs to display a drop down. The drop down elements don't change, but the individual item that's selected does. So, if the rank HTTP POST variable is set, we want to make sure the matching entry is selected.

The Device Search

by in CodeSOD on

I started writing a paragraph about why this code Gilda found was bad, and then I had to delete it all, because I wasn't putting the entire block in context. At a glance, this looks almost fine, but I thought I spotted a WTF. But only when I thought about the fact that this C code runs inside of a loop that I realized the real problem.

rsts = get_device_by_id ( movq_p->nxt_device_id, &devc ); if ( ( rsts == CC_VL_SUCCESS ) && ( strcmp ( devc.device_type, SPECIFIC_DEVICE ) == 0 ) ) { specific_device_flag = CC_VL_TRUE; } /* * Process device... */ if ( specific_device_flag ) { ... }

Tying Two Strings

by in CodeSOD on

Lets say you have a simple problem. You have a string variable, and you'd like to store that string in another variable. You have a vague understanding of string immutability and something about the way references work in C#, but you don't really understand any of that. So, what do you do?

Well, if you're Tina's co-worker, you do this:

Untimely Ripp'd

by in Error'd on

This week we bring you a whole set of submissions that prove, once again, that web programmers just can't keep track of time. But first, a sop with a regular. Is a flying NaN safer than a Camel? I wouldn't recommend making either a habit.

Friend Argle right, submissions to Error'd from actual desktop applications are rare. He explanes "I routinely expect this from websites. I did NOT expect to find it in MSFS. It came up when I deleted all the digits." Good for you, Mr. B. I can't type a lick without digits.

Compiling Datasets

by in CodeSOD on

Managing datasets is always a challenging task. So when Penny's co-worker needed to collect a pile of latitude/longitude positions from one dataset and prepare it for processing in a C++ program, that co-worker turned to the tools she knew best. Python and C++.

Now, you or I might have dumped this data to a CSV file. But this co-worker is more… performance minded than us. So the Python script didn't generate a CSV file. Or a JSON document. Or any standard data file. No, that Python script generated a C++ file.

Double Narcissism

by in CodeSOD on

In mythology, Narcissus was so enraptured by his own beauty that he turned away all potential lovers until he came across a still pool of water. Upon spying his reflection, he fell in love and remained there for the rest of his life. After his death, a narcissus flower grew in his place- a daffodil or jonquil.

One important element of Narcissus's myth is that while yes, he was incredibly self-absorbed, he was also beautiful. That's less true for this C# code from frequent commenter Sole Purpose Of Visit. There is nothing beautiful about this code.

Paste Parse

by in CodeSOD on

Sandra (previously) is still working with Bjørn. Bjørn also continues to like keeping things… simple.

"Simple" for Bjørn is "do as much in PHP as possible since I am okay at PHP, including templating out JavaScript. If I have any third party libraries, just copy and paste them into the project and never, ever use a bundler because WebPack is scary."

The Silent Partner

by in Feature Articles on

SOS Italian traffic signs in 2020.05

Lucio worked as a self-employed IT consultant. His clients tended to be small firms with equally small IT departments. When they didn't know where else to turn, they called on Lucio for help.


by in Error'd on

The submissions this week seemed to have coincidentally developed a theme of self-reference. You tell me.

First, persistent Caleb S. tried over and over again to submit this same item for our consideration. He called it a "space-enfolding bus" and said that "There's apparently more space in this Afternoon Tea bus than meets the eye -- you can book seats for 500 adults and 500 children." Alas, his submission came without an image, so we asked for a do-over. Dutifully done, Caleb's second and third attempts both reported "Please use the comments from when I tried to submit this without an image." With that behind us, here is the image from the final attempt.

The Wager

by in CodeSOD on

We've all been there. We need to make a change to the codebase or else. The right solution is going to take time and refactoring. There's a quick fix that will keep the production system from falling over and crushing the business. So you make the quick fix, with the idea that, eventually, you'll really fix it.

And eventually never comes.

Exceptional Flags

by in CodeSOD on

Something I see in a lot of code, and generally dislike, is this pattern:

if (debug) { print("Some debugging message"); }

Busy Busy Busy

by in CodeSOD on

One of the common mistakes in a beginner programmer is to wait using a busy loop. Need to pause a program? for(int i = 0; i < SOME_LARGE_NUMBER;i++) continue;

There are a lot of good reasons to not do this, but in microcontroller land, sometimes you actually do want to wait this way. There may be better ways, but there also might not- it depends on your specific constraints.

Switching Notes

by in CodeSOD on

"The app I work on is a 1.2MLOC big-ball-o-wtf," writes Mark B.

As with a lot of big piles of bad code, it's frequently hard to find a snippet that both represents the bad code and is concise enough to submit. In this case, the code in question shows a questionable grasp of both switch statements and enums.


by in Error'd on

This week we have a veritable grab-bag of all the most common sorts of website errors: the NaN, the null, the undefined, the bad text substitution and the wonky date math. Honestly, they're getting tedious. Somebody should build a tool to help developers scrub their code of impurities and dross. They could call it something catchy like, I dunno, purifier or lintbrush.

Timely Todd R. tells us "I left a window open in Workday for too long, and like a lot of other apps it threatened to log me out. I just wish I knew when that was..."

Crappy Wiring

by in Feature Articles on

Ellen had just finished washing her hands when her phone buzzed. It vibrated itself off the sink, so there was a clumsy moment when it clattered to the restroom floor, and Ellen tried to pick it up with wet hands.

After retrieving it and having another round of hand washing, Ellen read the alert: the UPS was in overload.

Stuttering Strings

by in CodeSOD on

Mario's team had a nasty stutter in the UI of their web application. Frequently, when going back to the server for data, the UI would just hang. The requests themselves were happening asynchronously, and it wasn't just network lag anyway- the server was able to serve up large JSON responses well within any reasonable timelines. Certainly nothing in the timing justified such a nasty UI hang. So what was going on?

Well, in many of the places where they were handling JSON responses, specifically large JSON responses, this code was copy-pasted in multiple places:

All the Single Objects

by in CodeSOD on

I have a bit of a vendetta against the Singleton pattern. It's not to say that I won't use it, it's just that it's a pattern that gets overused and misapplied. The result is, instead of guaranteeing that only one instance of an object exists (because there can be only one), and just reinvent global variables.

Today, George sends us some code that is in a Java factory class that constructs thread pools. In this case, the thread pool itself is returned as a singleton. I've got some questions about the logic of why that's the case, but that's what it is.

Classic WTF: Very, Very Well Documented

by in Feature Articles on
It's Independence Day in the US, but today, let's instead celebrate our dependence on good quality documentation. It matters. Even when we measure the size of that documentation in meters, instead of freedom units. Original -- Remy

Just about all of the systems I’ve written about here share quite a few things in common: they are poorly designed, poorly coded, and even more poorly documented. Today, I’m happy to share with you a system that doesn’t quite fit in with all the rest. It’s actually very sound software and, most of all, it’s well documented. Very, very well documented.

George Nacht is a software engineer in certain a Post-Communist European country. In the mid-1990’s, his government decided that it was time to replace their foreign, Soviet-era fighter jets with modern, less expensive aircrafts of domestic design. And since they were modernizing their fleet, they decided to modernize their pilot training as well. This meant that new, interactive flight-simulator software needed to be developed.


by in Error'd on

Knock knock.

Matthew shared a classic catch-22 that didn't catch any, explaining " is in the middle of a Reddit outage (actually, after the outage has been "restored" and we are "monitoring the situation"). The whole point of hosting a status page separately is so that it does not share common failure mechanism with the site being monitored!"