Switched On Readability
by in CodeSOD on 2026-11-30Jon has a team mate that has a coding quirk. They tend to write this pattern a lot.
switch (someEnum)
{
case EnumType::TargetValue: doStuff(); break;
default: doOtherStuff();
}
Jon has a team mate that has a coding quirk. They tend to write this pattern a lot.
switch (someEnum)
{
case EnumType::TargetValue: doStuff(); break;
default: doOtherStuff();
}
Uncharacteristically, I will be earnest for a moment. The holiday season can be a difficult time for many people, for many reasons that are beyond the scope of this column except for the fact that most of them are also wtfs. If you're one of those, stick around, because there are a lot of us here. And with that, on to BJH, who's a little behind.
B.J. H. reflects "Have there been any changes in my life in the last 55 years that could cause depression, other than the creation of the Internet?" I can think of a few but that's definitely on the list.
It's a holiday in the US, where we give thanks. Specifically, we give thanks that we're not working with the person responsible for this. Original --Remy
The Quine – i.e., a program that produces its own source code as output – lives in the esoteric realm of computing and computer science. It’s almost entirely useless, but usually pretty fun. The Quine Programmer, on the other hand, is among the pantheon of programming gods, sitting between The Great Abstractor and The PHP God.
The Quine Programmer has the uncanny gifts of being infinitely good at programming and infinitely insightful, thus allowing him to write a program to replace himself and all other programmers. The output of The Quine Programmer is system that’s fully configurable by the end-user; should the end-user want something changed, she can simply change it herself.
David came across some Java code. This particular block needed to, based on an integer masquerading as an enumerated type, return an amount of time to sleep. It has strong opinions about what should happen when you send it an invalid value:
private static int getTime(int mode) {
return switch (mode) {
case 0 -> 30 * SECOND;
case 1 -> 15 * SECOND;
case 2 -> 10 * SECOND;
case 3 -> 20 * SECOND;
case 4 -> 17 * SECOND;
case 5 -> 32 * SECOND;
default ->
// go to hell
1000000000;
};
}
At this point, each and every one of us knows more about Jensen Huang's sex life than I think any of us wanted to know. The actual scandal is the way he violated export controls to the tune of $12b in chips, but the scandal everyone is talking about is that he was "honey-trapped". A Chinese spy seduced him, got secrets out of him, and also he violated export controls for her. What can I say? People like thinking about attractive spies doing spy stuff.
It's ripe for joke of course, but it's also ripe for paranoia. I mean, think about it, we're all in tech. We all know insider secrets. At any moment, an extremely attractive person could seduce us and pump us for information about the inventory management process at Initech, and also seduce us. It could totally happen.
Earlier this year, I wrote a couple of times about my utility closet of infinite WTFs. After a total remodel and HVAC upgrade, I learned the demons had not been exorcised. Indeed, they still haunt the place, and now they're really showing off their sense of humor.
On a recent November morning with frost covering the ground and below-freezing temps, I awoke to find my house a chilly 14.4C / 58F. The gas furnace would try to start up, then fail with the message "Pressure Error - Your system may not be operational. Do not attempt to correct the problem yourself. Contact your dealer as soon as possible."
There's a bathroom on the right!
"Interesting temperature reading from WU" notes Peter G. "This must be what happens when a bulk liquid nitrogen carrier runs aground in your favourite holiday spot. Either that or you're supposed to take the average of +60 and -40 to get the actual temperature."
Today's anonymous submission is a blast from the past. This comes from an intranet HTML page that has been receiving continuous updates for some time. How long? Well, let's take a peek at how it does its layout.
<b>Extension:</b> x5555<br />
<b>Email:</b>: <a href="mailto:[email protected]"></a><br /><br />
</td>
<td width=140>
</td>
</tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</td>
</table>
</center>
<!-- END DIRECTORY -->
<tr><td><br /></td></tr>
</td>
</tr>
</table>
<!-- MATERIAL ENDS HERE -->
<br />
<br />
</td>
</tr>
</table>
</center>
</td>
</tr>
<tr><td width=987 height=4 background="../images/table_bottom_sidebar.jpg"></td></tr>
</table>
Years ago, Stefan's company was short handed, especially on the developer team. But they had a large hell-desk support team. And at some point, someone had the genius idea: "PHP is easy for anyone to learn, and so our helpdesk folks should have no problem. Let's hand them development tasks."
Which meant Stefan inherited lots of lines which look like this:
There's an unofficial category of posts here that I call "Somebody told us string builders were more efficient, so we always use string builders, regardless of whether or not that actually makes sense," or STUSBWMESWAUSBROWONTAMS, for short. Probably should workshop that name some.
In any case, Adam sends us a new entry for that collection:
Submitter Valts shares an enumerated mystery:
This happened a few years ago (before COVID). A colleague called me over because he couldn't make sense of the results he was getting from some MySQL queries in MySQL Workbench. I don't remember the queries in particular, but let's say
select * from payments where client_id=1234showed 12 rows, all having thesuccessfulfield set to1. But when you selectedselect count(*) from payments where client_id=1234 and successful=1you got back0rows. And this was reproducible on my machine, too. Yet in code similar queries worked just fine.
One of Sean's colleagues left Initech on good terms. It caused no small amount of surprise that the very next day their billing system started failing. The billing system which the colleauge had worked on.
No one truly suspected foul play, it was just a weird coincidence. Still, billing blowing up was a 5 alarm fire, so everyone was throwing every idea out about what could be the cause.
Look, I don't want to keep talking about security issues. Blame AI. Just another thing it ruined.
At this point, you've probably heard about *sshole. If you haven't, the quick summary: on some Linux systems, SSH will log you in to an account with no password if you supply a password greater than 256 characters long. Frequently, you might make accounts like root nominally inaccessible by giving it no password, so this is a big deal. Worse, it impacts varieties of Linux that use the musl implementation of libc, like Alpine- the kinds of varieties that run inside a container hosting a web app somewhere.
Venkat joined a new team in the middle of a big refactoring effort. The code was quite a mess, glued together by long Python scripts with main functions longer than a Tolstoy novel. It was this effort to clean up the code into neat modules that highlighted some logical issues with their implementation.
def generate_random_number():
""" Generate a 5 digit random number.
"""
return "".join(map(str, random.sample(range(0,10),5)))
We were just discussing TODO comments recently, and that motivated Bernard to send us this representative comment..
// TODO: This method should ideally be in tax frame work but due to
// the time constraint I am duplicating the code here.
// Needs to be refactored. Oct 28, 03.
"I Already Hate Running... I Don't Want To Have To Run Each Street A Second Time!" plods WeaponizedFun "I've gotten a couple of notifications from CityStrides today that they've updated streets for several cities, but it looks like they're doubling the effort it's going to take to finish completing these roads."
Foreign keys are an important part of making sure the entities in our relational database can be connected back together and queried correctly. It's part of proper data normalization. This isn't shocking, of course: the order line table has a foreign key over to the products table, so that every line item points to a product we sell. That's database 101. Database 201, you'd also think about the times where you have a hierarchy of records, where say, every Employee has a ManagerId, which is a foreign key back to the Employee table itself (and in database 301, you'll understand why having a ManagerId field is a terrible choice, but that's neither here nor there).
The important thing here is that foreign keys are very common, and foreign keys pointing back to the same table are also very common.
Alastair found this comment in his codebase, and wondered, "who wrote this comment?" A quick blame answered the question: he did. He did not, however, write the code.
public function getAllMailers() {
// This function neither returns Mailers, nor all of them.
...
}
When writing Perl, it's not unusual to want to die. The die function ends your Perl program with an error string, and you'll often see code like: die "My error" unless $i > 5 or die "Other error" if check(), because Perl just loves the backwards conditionals. What's even more fun with die is how it behaves with eval blocks, so it doesn't always kill your program, sometimes it is how you pass error strings back out of sections of your program.
And poor Bobby has inherited some Perl that just really loves to die.
"TODO" comments are an inescapable part of our work. Yes, yes, you should just do it right the first time, everything should probably have a ticket in whatever your ticket system is for visibility, but at some point, you're just going to leave a "TODO" behind.
But hopefully, the TODO gets TODONE, which is not what happened in Sam C's codebase.