Remy Porter

Computers were a mistake, which is why I'm trying to shoot them into space. Editor-in-Chief for TDWTF.

Jun 2019

Classic WTF: Code Comedians

by in Coded Smorgasbord on
Everybody's a comedian, until the joke's on them. We close out this week of classics with some code and comments by people who were being funny. We'll return to our regularly scheduled programming next week! Original. --Remy

When it comes to bad code, everybody thinks they’re a comedian. Heck, look at us! Stupid programmer jokes are a game everyone can play, though, so let’s enjoy an evening at the Improv with some code comedians.

Brian sends us this enum, which I’m sure was very funny back in 2007.


Get Out Your Decoder Ring

by in CodeSOD on

Back in the late 60s, early 70s, “Fourth Generation Languages” (4GL) seemed like the future. “Write programs without a programmer!” they promised. “It’s a specification-based language, you just tell the computer what should happen, and it figures out how to do it!”

The most famous and probably most widely deployed 4GL, when all its variants and dialects are taken as a single unit, has to be SQL. SQL is the epitome of a specification-based language: each SQL statement represents an expression in relational algebra, and the database gets to use its own internal logic for deciding the best way to execute that statement, making database tuning a dark art involving statistical modeling and a lot of, “I dunno, but when I use this hint it runs fast.”


The Map you Pay For

by in CodeSOD on

Soraya’s company recently decided to expand the payment options that they support. This meant integrating “Inipay”, Initech’s API for handling payment processing globally. This particular API is open sourced, which means that Soraya was able to investigate exactly how the sausage was made.

Many of the classes were tagged as being @author auto create. In fact, there were about 2,000 such classes, all nearly identical aside from a few minor differences. What got Soraya’s attention though was that each of them referred to InipayObject and InipayHashMap. Re-implementing standard classes is always a concern.


ToArray, then REST a bit

by in CodeSOD on

Mandy’s company was brought on to port some REST APIs to Java for a client. Those APIs were written in an in-house, proprietary programming language. Possibly this was a deployment of BobX? Regardless of what the in-house language was, it was everything one would expect from the Inner-Platform Effect. Weird, complicated, tortured logic.

Somewhere in Mandy’s company, a pointy-haired-boss decided they’d throw a junior developer at this. “They did a REST API during their internship, how hard could translating this logic be?” Well, that junior developer didn’t understand the ins-and-outs of Java that well. They certainly didn’t understand the original APIs they were trying to port. The result is that they tried to follow the twisted logic of the in-house language while trying to fumble through Java.


The Honeypot

by in CodeSOD on

Pitor works for a web development shop. They’ll develop and design sites, usually pretty simple ones, for their customers. They’ll host them. They’ll update them. Every once in awhile, a customer will think “we could do this cheaper in house!” and takes their site and their contract to a cheap webhost.

Sometimes, those customers come back when they realized their mistake.


Whose Tern is it to Play?

by in CodeSOD on

Every once in awhile, someone sends us some code from a game. Now, I’ve never delved deep into game development, aside from making a 3D asteroids game as a final project for a class twenty years ago, but I’ve also read an article about how fast inverse square root works, and know that you shouldn’t blow in a Nintendo cartridge, so I’m basically an expert, and I understand that under the constraints of games, some of the rules about clarity and maintainability go out the window.

But Adam S found some code that’d be just plain bad in any context:


This Null Leaves Me Feeling Empty

by in CodeSOD on

Stella needs to interface with a cloud-hosted marketing automation system. The documentation isn’t particularly great, and her organization doesn’t have anyone with any serious experience with the stack, so she’s been trying to find examples and wrapper libraries that can make it easier.

She found one. While digging through the wrapper code, she found this block:


Is Thinking Range Empty?

by in CodeSOD on

Susi inherited some code which she fortunately wasn't expected to maintain. She had a worse problem: she was expected to figure out what it did so that a new version of the software could be created. No one actually understood all the ins-and-outs of the software, there was no document that fully specified what it did, but it was absolutely business critical and every feature needed to continue to work, even if no one knew exactly what those features were.

Features and functionality aside, internally, everything was stringly typed, and I do mean everything. Why use a struct in C++ when you can use a character delimited string? Why use a class when you can instead use multiple different kinds of delimiters to mean different things? Susi found cases where they stretched to delimiters involving characters Susi didn't even know existed, like the double o̿verscore.


Sorted by Title

by in CodeSOD on

Dictionaries/Maps are usually implemented on top of some sort of hashing system. This isn’t precisely required, but it allows extremely fast access by key. The disadvantage is that the data isn’t stored in any human-friendly order.

Cicely’s co-worker had a problem with this. They wanted to store key value pairs- specifically, the titles of a media item, and the actual object representing the media items. They wanted to be able to fetch items by their title, but they also wanted to be able to present the items sorted by their title.


Drink from the Font of Wisdom

by in Feature Articles on

A long time ago, George G started at Initech’s downtown office. They had just rented a few floors in an old office building that had recently transitioned from “urban blight” to “twee coffee shops on the first floor and the scent of shoe polish and fresh leather on every floor.”

It was a big space, and George was in the part of his career where he merited a private office with a view of the alley.


This Event is Quite the Do

by in CodeSOD on

Benjamin inherited some code from a fellow developer. The original author of this code wrote a lot of code for the company, and that code drives a lot of products which make the company piles of money. Tired of making money, that developer left to go open a restaurant.

Which means Benjamin is now responsible for maintaining code which lives in 15,000 line files where class-level variables are essentially treated as globals. There's also a lot of misunderstandings about how Windows Forms GUIs work.