Recent Articles

Sep 2021

The Boulder Factory

by in Feature Articles on

Like a lot of HR systems, the one at Initech had grown into a complicated mess of special cases, edge cases, and business rules that couldn't be explained but had to be followed.

Mark was assigned to a project to manage another one of those special cases: Initech had just sold one of its factories. Their HR system needed to retain information about the factory and its employees up until the point of the sale, but it also needed to be disconnected from some future processing- they certainly didn't want to send anybody any paychecks, for example. But not all processing. If an employee had started a health insurance claim before the factory was sold, they needed to keep that active in the system until it was completed (but also not allow the employee to file new claims).


by in Feature Articles on

A surprising amount of the world runs on FORTRAN. That's not to say that huge quantities of new FORTRAN are getting written, though it's far from a dead language, but that there are vital libraries written fifty years ago that are still used to this day.

But the world in which that FORTRAN was written and the world in which we live today is wildly different. Which brings us to the story of George and Ike.

Golfing Over a Log

by in CodeSOD on

Indirection is an important part of programming. Wrapping even core language components in your own interfaces is sometimes justifiable, depending upon the use cases.

But like anything else, it can leave you scratching your head. Sam found this bit of indirection in a NodeJS application:

Terned Around About Nullables

by in CodeSOD on

John H works with some industrial devices. After a recent upgrade at the falicity, the new control software just felt like it was packed with WTFs. Fortunately, John was able to get at the C# source code for these devices, which lets us see some of the logic used…

public bool SetCrossConveyorDoor(CrossConveyorDoorInfo ccdi, bool setOpen) { if (!ccdi.PowerBoxId.HasValue) return false; ulong? powerBoxId = ccdi.PowerBoxId; ulong pbid; ulong ccId; ulong rowId; ulong targetIdx; PBCrossConveyorConfiguration.ExtractIdsFromPowerboxId(powerBoxId.Value, out pbid, out ccId, out rowId, out targetIdx); TextWriter textWriter = Console.Out; object[] objArray1 = new object[8]; objArray1[0] = (object) pbid; objArray1[1] = (object) ccId; objArray1[2] = (object) setOpen; object[] objArray2 = objArray1; powerBoxId = ccdi.PowerBoxId; ulong local = powerBoxId.Value; objArray2[3] = (object) local; objArray1[4] = (object) pbid; objArray1[5] = (object) ccId; objArray1[6] = (object) rowId; objArray1[7] = (object) targetIdx; object[] objArray3 = objArray1; textWriter.WriteLine( "Sending CCD command to pbid = {0}, ccdId = {1}, Open={2}, orig PowerBoxId: {3} - divided:{4}/{5}/{6}/{7}", objArray3); bool? nullable1 = this.CopyDeviceToRegisters((int) (ushort) ccId); if ((!nullable1.GetValueOrDefault() ? 1 : (!nullable1.HasValue ? 1 : 0)) != 0) return false; byte? nullable2 = this.ReadDeviceRegister(19, "CrossConvDoor"); byte num = nullable2.HasValue ? nullable2.GetValueOrDefault() : (byte) 0; byte registerValue = setOpen ? (byte) ((int) num & -225 | 1 << (int) targetIdx) : (byte) ((int) num & -225 | 16); Console.Out.WriteLine("ccdid = {0} targetIdx = {1}, b={2:X2}", (object) ccId, (object) targetIdx, (object) registerValue); this.WriteDeviceRegister(19, registerValue, "CrossConvDoor"); nullable1 = this.CopyRegistersToDevice(); return nullable1.GetValueOrDefault() && nullable1.HasValue; }

;pam ;pam ;pam ;pam

by in Error'd on

One of this week's entries is the type that drives me buggy. Guess which one.

Regular contributor Pascal splains this shopping saga: "Amazon now requires anti-virus software to have an EPA Registration number."

A Dash of SQL

by in CodeSOD on

As developers, we often have to engage with management who doesn't have a clue what it is we do, or how. Even if that manager was technical once, their technical background is frequently out of date, and their spirit has been sapped by the endless meetings and politics that being a manager entails. And it's often these managers who have some degree of control over where our career is going to progress, so we need to make them happy.

Which means… <clickbait-voice>LEVEL UP YOUR CAREER WITH THIS ONE SIMPLE TRICK!</clickbait-voice>. You need to make managers happy, and if there's one thing that makes managers happy, it's dashboards. Take something complicated and multivariate, and boil it down to a simple system. Traffic lights are always a favorite: green is good, red is bad, yellow is also bad.

Some Version of a Process

by in Feature Articles on

When you're a large company, like Oracle, you can force your customers to do things your way. "Because we said so," is something a company like that can get away with. Conversely, a small company is more restricted- you have to work hard to keep your customers happy.

When Doreen joined Initech, they were a small company with a long history and not too many customers. In the interests of keeping those customers happy, each customer got their own custom build of the software, with features tailored to their specific needs. So, Initrode was on "INITRODE.9.1", while the Soggy Beans coffee shop chain was on "SOGGY.5.2". Managing those versions was a pain, but it was Doreen's boss, Elliot, who ensured that pain escalated to anguish.


by in CodeSOD on

When Daniel was young, he took one of those adventure trips that included a multi-day hike through a rainforest. At the time, it was one of the most difficult and laborious experiences he'd ever had.

Then he inherited an antique PHP 5.3 application, written by someone who names variables like they're spreadsheet columns: $ag, $ah, and $az are all variables which show up. Half of those are globals. The application is "modularized" into many, many PHP files, but this ends up creating include chains tens of files deep, which makes it nigh impossible to actually understand.

Expiration Dates

by in CodeSOD on

Last week, we saw some possibly ancient Pascal code. Leilani sends us some more… modern Pascal to look at today.

This block of code comes from a developer who has… some quirks. For example, they have a very command-line oriented approach to design. This means that, even when making a GUI application, they want convenient keyboard shortcuts. So, to close a dialog, you hit "CTRL+C", because who would ever use that keyboard shortcut for any other function at all? There's no reason a GUI would use "CTRL+C" for anything but closing windows.

In Other Words

by in Error'd on

We generally don't like to make fun of innocent misuses of a second language. Many of us struggle with their first. But sometimes we honestly can't tell which is first and which is zeroeth.

Whovian stombaker pontificates "Internationalization is hard. Sometimes, some translations are missing, some other times, there are strange concatenations due to language peculiarities. But here, we have everything wrong and no homogeneity in the issues."

Subbing for the Subcontractors

by in CodeSOD on

Back in the mid-2000s, Maurice got less than tempting offer. A large US city had hired a major contracting firm, that contracting firm had subcontracted out the job, and those subcontractors let the project spiral completely out of control. The customer and the primary contracting firm wanted to hire new subcontractors to try and save the project.

As this was the mid-2000s, the project had started its life as a VB6 project. Then someone realized this was a terrible idea, and decided to make it a VB.Net project, without actually changing any of the already written code, though. That leads to code like this:

The Programmer's Motto and Other Comments

by in CodeSOD on

We've got a lovely backlog of short snippets of code, and it's been a long time since our last smorgasbord, so let's take a look at some… choice cuts.

Let's open with a comment, found by Russell F:

Wise About Bits

by in CodeSOD on

The HP3000 was the first mini-computer that supported time-sharing. It launched in 1972, and HP didn't end-of-life it until 2010, and there are still third-party vendors supporting them.

Leonora's submission is some code she encountered a number of years ago, but not as many as you might think. It's in Pascal, and it's important to note that this version of Pascal definitely has bitwise operators. But, if you're programming on a 40 year old minicomputer, maybe you couldn't do an Internet search, and maybe Steve from down the hall had bogarted the one manual HP provided for the computer so you can't look it up because "he's using it for reference."

A Coded Escape

by in CodeSOD on

When evaluating a new development tool or framework, the first thing the smart developer does is check out the vendor documentation. Those docs will either be your best friend, or your worst enemy. A great product with bad documentation will provide nothing but frustration, but even a mediocre product with clean and clear documentation at least lets you get useful stuff done.

Stuart Longland's company has already picked the product, unfortunately, so Stuart's left combing through the documentation. This particular product exposes a web-socket based API, and thus includes JavaScript samples in its documentation. Obviously, one could use any language they like to talk to web-sockets, but examples are nice…


by in Error'd on

Despite literally predating paper, passcodes and secret handshakes continue to perplex programmers, actors, and artists alike.

For our first example, auteur Andy stages a spare play in three acts.
Nagg: Hello I'm not the account owner and shouldn't be logged in to this account. Can you help me?
Nell: Sure, here are the owner's credit card details. Please use those to say that you are the account owner.

Going Through Some Changes

by in CodeSOD on

Dave inherited a data management tool. It was an antique WinForms application that users would use to edit a whole pile of business specific data in one of those awkward "we implemented a tree structure on top of an RDBMS" patterns. As users made changes, their edits would get marked with a "pending" status, allowing them to be saved in the database and seen by other users, but with a clear "this isn't for real yet" signal.

One developer had a simple task: update a text box with the number of pending changes, and if it's non-zero, make the text red and boldfaced. This developer knew that some of these data access methods might not return any data, so they were very careful to "handle" exceptions.

Columns of a Constant Length

by in CodeSOD on

Today's submitter goes by "[object Object]", which I appreciate the JavaScript gag even when they send us C code.

This particular bit of C code exists to help output data in fixed-width files. What you run into, with fixed-width files, is that it becomes very important to properly pad all your columns. It's not a difficult programming challenge, but it's also easy to make mistakes that cause hard-to-spot bugs. And given that most systems using fixed-width files are legacy systems with their own idiosyncrasies, things could easily go wrong.


by in CodeSOD on

Shalonda inherited a C# GUI application that, if we're being charitable, has problems. It's slow, it's buggy, it crashes a lot. The users hate it, the developers hate it, but it's also one of the core applications that drives their business, so everyone needs to use it.

One thing the application needs to do is manage a list of icons. Each icon is an image, and based on user actions, a new icon might get inserted in the middle of the list. This is how that happens:

Classic WTF: Crazy Like a Fox(Pro)

by in Feature Articles on
It's Labor Day in the US. We're busy partaking in traditional celebrations, which depending on who you ask, is either enjoying one of the last nice long weekends before winter, or throwing bricks at Pinkertons. So we dig back into the archives, for a classic story about databases. Original --Remy

“Database portability” is one of the key things that modern data access frameworks try and ensure for your application. If you’re using an RDBMS, the same data access layer can hopefully work across any RDBMS. Of course, since every RDBMS has its own slightly different idiom of SQL, and since you might depend on stored procedures, triggers, or views, you’re often tied to a specific database vendor, and sometimes a version.

Keulemans Chama fox.png

And really, for your enterprise applications, how often do you really change out your underlying database layer?

Just Doer It

by in Error'd on

Testing in production again, here's five fails for the fifth day of the week. Or the sixth. Or is it the fourth?

Anonymous Ignoronymous declares "Dude! Science tests were never popular!"

Dangerous Tools for Dangerous Users

by in CodeSOD on

Despite being a programmer, I make software that goes in big things, which means that my workplace frequently involves the operation of power tools. My co-workers… discourage me from using the power tools. I'm not the handiest of people, and thus watching me work is awkward, uncomfortable, and creates a sense of danger. I'm allowed to use impact drivers and soldering irons, but when it comes time to use some of the more complex power saws, people gently nudge me aside.

There are tools that are valuable, but are just dangerous in the hands of the inexperienced. And even if they don't hurt themselves, you might end up boggling at the logic which made them use the tool that way. I'm talking, of course, about pre-compiler macros.

Maintaining Yourself

by in CodeSOD on

When moving from one programming language to another, it's easy to slip into idioms that might be appropriate in one, but are wildly out of place in another. Tammy's company has some veteran developers who spent most of their careers developing in COBOL, and now' they're developing in C#. As sufficiently determined programmers, they're finding ways to write COBOL in C#. Bad COBOL.

Methods tend towards long- one thousand lines of code isn't unusual. Longer methods exist. Every method starts with a big long pile of variable declarations. Objects are used more as namespaces than anything relating to object-oriented design. So much data is passed around as 2D arrays, because someone liked working with data like it lived in a table.