Recent Articles

Oct 2023

Legacy Horrors

by in CodeSOD on

Today is Halloween, a day filled with chills, horrors, and Jamie Lee Curtis. An interesting aspect of horror movies is how often the roots of the horror lurk in the past. Michael Meyers had been in an asylum for decades before his infamous Halloween rampage. Midsommar represents a centuries old tradition. Barbarian is rooted in sins committed a generation prior. Freddy Krueger was the manifestation of the sins of our protagonists' parents. Hell, even Dracula is a menace that had been lurking for centuries before our story begins.

In honor of that, we're going to look at some code from Davide. Like so much classic horror, the seeds of this sin were planted many, many years before Davide arrived.


High Performance Query

by in CodeSOD on

Aaron was doing some work with a high-performance-computing platform. The kind of thing that handles complex numerical simulations divided across farms of CPUs, GPUs, FPGAs, and basically anything else that computes.

The system comes with a web GUI, and the code for the web GUI is… well… let's just look at the comment on a method.


Look, Up In the Sky!

by in Error'd on

"My FB got HACKED" wrote an anonymous contributor. "Verification codes box sooo not funny 🤦🤦🤦🤦" Not just one facepalm, but four.


End this Date Now

by in CodeSOD on

Once upon a time, someone wanted to store date ranges in a database. And so, they started down the obvious path of having two columns, one to hold the starting date of the range, and one to hold the ending date. But even going down that route, they tripped and fell, because they ended up with two database fields name Startdate and StartdateStart. Startdate was the end of the period.

You might be thinking, "Well, at least they used the database datetime types," but on that front, you'd be wrong. They used text, and in some cases, instead of Startdate holding a date, it held a string in the format 22-08-2022 to 27-08-2023.


It's All Right

by in CodeSOD on

Mark recently inherited a Java codebase that… well, it's going to need some support. He thought things were bad when he encountered this:

 if (isCheckedOut.equalsIgnoreCase("0")) {
	…
 }

Locally Variable

by in Feature Articles on

Henrik H was hired by a customer to fix some bugs in their application. The main one was that their C# web app didn't properly track the user's culture settings. Henrik spoke with their internal developer, who originally wrote the application, and was told: "Sometimes the culture name and LCID is out of sync. I don't understand why?"

Well, from that description, Henrik didn't understand either. Why was there a separate name and what the heck was LCID? Why were two variables getting synced? The only answer would be in the code, so Henrik dug in.


Cast a Different Spell

by in CodeSOD on

The rule of spelling in programming is that it doesn't matter if you spell it correctly, only if you spell it consistently. Which is fine if you're working alone, but we rarely work alone. And unless you're entire team shares the same misspelling habits, you're in for trouble when one person insists on "calander" while everyone else uses "calender".

Fortunately, Jonathon's co-worker had a solution to this problem.


Self Driving Level NaN

by in Error'd on

This week, Harry Altman teaches us how to make sure that autoautomobiles don't crash into your house. It's not immediately obvious, and the answer to the puzzle borders on philosophical.

But first, an anonymous reader wrote "I found this in a practice exam for an Azure Certification, !(Azure Service Bus) story." I believe him.


Set Your Performance Target

by in CodeSOD on

The power of SQL is that you describe to the database what you want, and the database figures out how to execute that query as efficiently as possible. This means that, at least in theory, you optimize your database access not by changing the query, but by tuning the database to run that query efficiently.

In practice, every database has quirks, and frequently you do tune the query a bit, to trick the optimizer into running it efficiently. And sometimes, you have to modify the query because people are dumb.


Write, Write Again

by in CodeSOD on

Melissa was trying to figure out why an old application wasn't writing out a data file when commanded to do so. It was an implemented feature, it should work, it had worked at one point- but it wasn't working now.

She traced through the C code and found this:


Taking the Temperature

by in CodeSOD on

Mr. TA inherited some C# code that communicates with a humidity and a temperature sensor. Each sensor logs a series of datapoints as they run, and can provide them as an array of data points.

This leads to this code:


If You're First

by in CodeSOD on

Laurie has been supporting an internal application for a few years. The code is a mess, and while she wasn't at the company for the early stages of development, tales are told about it- it was chaotic, it was badly estimated, it was wildly over budget, the latter phases were a crunch where ten developers were shoved onto the project at the last second.

Today, it works- mostly. But it provides plenty of support tickets for Laurie, and demonstrates some WTFs.


Cold Shoulder'd

by in Error'd on

Winter is coming to New Mexico this year with a vengeance. It should be fine if you just stay out of the wind.

First, to get this out of the way, never let it be said that we at TDWTF won't take our own lumps. The Beast in Black has a beef with our grammar, and technically he is correct. "So Meta, Especially This Atrocity..."


Nada

by in CodeSOD on

In the cinematic classic They Live, the protagonist is a drifter named "Nada"- nothing. Zizek derives much meaning from this, which is an entertaining rant if nothing else.

But Nada appears in other places, like this code found by JMM.


Testing with a Lisp

by in CodeSOD on

Dom works on a codebase which has fallen victim to Greenspun's Tenth Rule. Yes, they've implemented a user customization system that is an "ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."

Said Lisp implementation started its life as a Java backend, but over the years got ported into Flash apps, iOS, and most recently the JavaScript front end.


Table This Until Tomorrow

by in CodeSOD on

One of the secret powers of a relational database system, is that the query describing the data you want and the execution path for fetching it have no direct connection. The database is free to find optimizations and alternate paths for fetching the data. Coupled with database configurations like indexes and partitions, you can frequently take huge quantities of data and run arbitrary queries against it without having to think too hard about performance when writing the query (while spending a lot of time thinking about performance as you manage indexes and statistics gathering).

That doesn't mean that we don't see some… unique choices in terms of how we organize our data "for performance". Chris needed to add a field to one of their data models. Said data model was generated from object oriented mapping, so it seemed like it should be easy to do. Just add a field to the object oriented model, generate a migration script, and then start the rollout process.


Type of Expression

by in CodeSOD on

Several months ago, Rebecca's predecessor wrote some Perl code to traverse a JSON-esque data-structure. It was an hash map that could contain values, arrays, or more hashes.

Said predecessor wrote the code, had it reviewed, and tested it. It rolled out in production, and for three months, everything was fine. Three months was also long enough for predecessor to take a new job elsewhere, which left Rebecca as the sole support when it broke.


Tomorrow, and tomorrow

by in Error'd on

No fail merges today, no fexts or flubstitutes. Just flubs, subbed by a pantheon of old hands. I think everyone represented has been active here for at least five years, save perhaps our first, anonymous submission!

An anonymous Aussie shared a snippet of source from the ozpo website. Notice that even their "suggested example" doesn't fit. "Australia Post's most public of many rule mismatches in their n-number of systems chained together. The description text field on the printed label? Sure, there's space for over 900 characters."


Status Games

by in CodeSOD on

There is an entire category of WTF rooted in not understanding what HTTP status codes mean. As a quick refresher, the basic pattern is:

  • 100: hey, I got a note
  • 200: everything is cool
  • 300: look over here
  • 400: the client screwed up
  • 418: I am a teapot
  • 500: the server screwed up

Inside those ranges, there are more specific codes that provide the details, but most WTF code can't even get that much right.


Modular Dependencies

by in Feature Articles on

Many years ago, Valts and his spouse both worked for the same company. The company had an ERP system that started its life as a product back when ERP systems were novel and new. It was written in Delphi, and it was huge- so huge that the company needed to hack the Delphi linker to handle its size.

Well, their company got swallowed up by Initech, and after the buyout, things changed. Valts left, and a few years later so did his spouse. But they kept in touch with their colleagues, so it was over dinner that former co-worker Viktorija related the recent disaster she had stumbled across.


Teaching Programming

by in CodeSOD on

Gracie had a friend who was interested in becoming a teacher. To get admitted into a teaching program at the local university, the friend needed to take an admissions test, to prove they were teaching material.

Said friend tried to retrieve their test results, and the page glitched out. Gracie, who was handy, offered to see if she could identify the problem- likely an ad-blocker extension or something was breaking a script. A few minutes in the browser debugging tools, however, showed that the script came pre-broken.


Easy Reader Version

by in CodeSOD on

Ensuring you code is readable is arguably one of the most important things you can do after ensuring it is correct. The real question is: readable to whom? Because apparently, some people have odd ideas about readability. Like Evan's co-worker.

/* dlgAdvanced.vb */
Me.btn1.Text = "Yes to All"
Me.btn1.DialogResult = Windows.Forms.DialogResult.Yes And Windows.Forms.DialogResult.Ignore ''Easy Readability, but the real value is 4 (DialogResult.Retry)