Remy Porter

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

Oct 2018

A Tern at the Build Process

by in CodeSOD on

Justin Self inherited an internal build tool. Rome may not have been built in a day, but this tool was. It “simplifies” provisioning development environments, claiming machines in the environment for certain tasks, and so on.

(e.BuildStatus == null ? 
    (e.Branch == null ? "" : ($"\nBranch: <{e.BranchUrl}|{e.Branch}>")) :
    ($"\n{(e.BuildStatus == "Building" ? "Building" : e.BuildStatus == "Success" ?
    $"Built" : "Build failed")}: <{(e.BuildStatus == "Success" ? 
    e.BuildReleaseUrl : e.BuildUrl)}|{e.BuildRelease}>") + 
    $"{GetCardUrl(e.Branch)}") +
    $"\n{(e.DeployStatus == "Deploying" ? 
    "Deploying" : e.DeployStatus == "Success" ? 
    "Deployed" : "Deploy failed")}: 
    <{e.DeployUrl}|{e.DeployRelease}>{GetCardUrl(e.DeployRelease)}"

Created Equal

by in Representative Line on

Let's say you have an enum. You have an array of objects, where one of the fields is of that enum type. You want to filter the array of objects where the value of the enum is PAYMENTMETHOD.

You also hate equals signs.


We Tried Nothing

by in CodeSOD on

Initrode bought a UI widget library from Initech. Years passed, and eventually Initech went under. Initrode kept on keeping on, and kept using the library. Management shuffles happened, IT got downsized, and new development got outsourced.

Merlin B worked for the company that got the contract. Somehow, someone got the source code from Initech's GUI library.


Longer Isn't Better

by in CodeSOD on

Andrew H writes “this is an interface for one of our Spring Data repositories”. If you’ve ever looked at Spring’s documentation, you know the punchline. Spring has certain naming conventions that have become a notorious.

Spring Data is an ORM, and among other things, it allows you to design interfaces which are translated into a series of queries based on the naming conventions. So, for example, a method named findDistinctByTenantId would turn into a query in the database. It’s a useful convenience for simple CRUD operations, but for more complex queries, you’re still better off writing your SQL in an @Query annotation. SQL is still the best way to build complicated RDBMS queries.


The Theater of the Mind

by in Feature Articles on

Hamza has some friends in the theater business. These friends had an in-house developed Java application to manage seating arrangements, and they had some problems with it. They had lots of problems with it. So Hamza cut them a deal and agreed to take a look.

There were the usual litany of problems: performance was garbage, features bugged out if you didn’t precisely follow a certain path, it crashed all the time, etc. There was also an important missing feature.


A Load of ProductCodes

by in CodeSOD on

“Hey, Kim H, can you sit in on a tech-screen for a new hire?”

The Big Boss had a candidate they wanted hired, but before the hiring could actually happen, a token screening process needed to happen. Kim and a few other staffers were pulled in to screen the candidate, and the screen turned into a Blue Screen, because the candidate crashed hard. Everyone in the room gave them a thumbs down, and passed their report up the chain to the Big Boss.


My Condition is Complicated

by in CodeSOD on

Anneke’s organization is the sort of company where “working” takes precedence over “working well”. Under-staffed, under-budgeted, and under unrealistic deadlines, there simply isn’t any emphasis on code quality. The result is your pretty standard pile of badness: no tests, miles of spaghetti code, fragile features and difficult to modify implementations.

Recently, the powers that be discovered that they could hire half a dozen fresh-out-of-school developers on the cheap, and threw a bunch of fresh-faced kids into that mountain of garbage with no supervision. And that’s how this happened.


Eine Kleine ProductListItems

by in CodeSOD on

Art received a job offer that had some generous terms, and during the interview process, there was an ominous sense that the hiring team was absolutely desperate for someone who had done anything software related.

Upon joining the team, Art found out why. Two years ago, someone had decided they needed to create a web-based storefront, and in a fit of NIH syndrome, it needed to be built from scratch. Unfortunately, they didn't have anyone working at the company with a web development background or even a software development background, so they just threw a book on JavaScript at the network admin and hoped for the best.


Boldly Leaping Over the Span

by in CodeSOD on

No one writes HTML anymore. We haven’t for years. These days, your HTML is snippets and components, templates and widgets. Someplace in your application chain, whether server-side or client-side, or even as part of a deployment step, if you’re using a static site generator, some code mashes those templates together and you get some output.

This has some side effects, like div abuse. Each component needs its own container tag, but we often nest components inside each other. Maybe there’s a span in there. If the application is suitably HTML5-y, maybe it’s sections instead.


Round Two

by in CodeSOD on

John works for a manufacturing company which has accrued a large portfolio of C++ code. Developed over the course of decades, by many people, there’s more than a little legacy cruft and coding horrors mixed in. Frustrated with the ongoing maintenance, and in the interests of “modernization”, John was tasked with converting the legacy C++ into C#.

Which meant he had to read through the legacy C++.


Tern The Bool Around

by in CodeSOD on

Some say that the only reason I like ternary code snippets is that it gives me an opportunity to make the title a “tern” pun.


A Floating Date

by in Feature Articles on

Enterprise integration is its own torturous brand of software development. Imagine all the pain of inheriting someone else's code, but now that code is proprietary, you can't modify it, poorly documented, and exposes an API that might solve somebody's problem, but none of the problems you have, and did I say poorly documented? I meant "the documentation is completely inaccurate and it's possible that this was intentional".

Michael was working on getting SAP integrated to their existing legacy systems. This meant huge piles of bulk data loading, which wasn't so bad- they had a third party module which promised to glue all this stuff together. And in early testing phases, everything went perfectly smooth.


Break Out of your Parents

by in CodeSOD on

When I first glanced at this submission from Thomas, I almost just scrolled right by. “Oh, it’s just another case where they put the same code in both branches of the conditional,” I said. Then I looked again.

if (obj.success) {
    //#BZ7350
    for (i = 0; i < parent.length; i++) {
        try {
            parent[i]['compositionExportResultMessage'](obj.success, obj.response, 'info');
            break;
        } catch (e) { }
    }
}
else {
    //#BZ7350
    for (i = 0; i < parent.length; i++) {
        try {
            parent[i]['compositionExportResultMessage'](obj.success, obj.response, 'error');
            break;
        } catch (e) { }
    }
}

An Error on Logging

by in CodeSOD on

The beauty of a good logging system is that it allows you to spam logging messages all through your code, but then set the logging level at runtime, so that you have fine grained control over how much logging there is. You can turn the dial from, “things are running smooth in production, so be quiet,” to “WTF THINGS ARE ON FIRE GODS HELP US WHAT IS GOING ON CAN I LAUNCH A DEBUGGER ON THE PRODUCTION ENVIRONMENT PLEASE GOD”.

You might write something like this, for example:


Pointed Array Access

by in CodeSOD on

I've spent the past week doing a lot of embedded programming, and for me, this has mostly been handling having full-duplex communication between twenty devices on the same serial bus. It also means getting raw bytes and doing the memcpy(&myMessageStructVariable, buffer, sizeof(MessageStruct)). Yes, that's not the best way, and certainly isn't how I'd build it if I didn't have full control over both ends of the network.

Of course, even with that, serial networks can have some noise and errors. That means sometimes I get a packet that isn't the right size, and memcpy will happily read past the end of the buffer, because my const uint8_t * buffer pointer is just a pointer, after all. It's on me to access memory safely. Errors result when I'm incautious.