How About Next Month
by in CodeSOD on 2024-03-18Dave's codebase used to have this function in it:
public DateTime GetBeginDate(DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, 01).AddMonths(1);
}
Code Snippet Of the Day (CodeSOD) features interesting and usually incorrect code snippets taken from actual production code in a commercial and/or open source software projects.
Dave's codebase used to have this function in it:
public DateTime GetBeginDate(DateTime dateTime)
{
return new DateTime(dateTime.Year, dateTime.Month, 01).AddMonths(1);
}
Rui recently pulled an all-nighter on a new contract. The underlying system is… complicated. There's a PHP front end, which also talks directly to the database, as well as a Java backend, which also talks to point-of-sale terminals. The high-level architecture is a bit of a mess.
The actual code architecture is also a mess.
Donald was cutting a swathe through a jungle of old Java code, when he found this:
protected void waitForEnd(float time) {
// do nothing
}
FreeBSDGuy sends us a VB .Net snippet, which layers on a series of mistakes:
If (gLang = "en") Then
If (item.Text.Equals("Original")) Then
item.Enabled = False
End If
ElseIf (gLang = "fr") Then
If (item.Text.Equals("Originale")) Then
item.Enabled = False
End If
Else
If (item.Text.Equals("Original")) Then
item.Enabled = False
End If
End If
Today, John sends us a confession. This is his code, which was built to handle ISO 8583 messages. As we'll see from some later comments, John knows this is bad.
The ISO 8583 format is used mostly in financial transaction processing, frequently to talk to ATMs, but is likely to show up somewhere in any transaction you do that isn't pure cash.
It's a nearly universal experience that the era of our youth and early adulthood is where we latch on to for nostalgia. In our 40s, the music we listened to in our 20s is the high point of culture. The movies we watched represent when cinema was good, and everything today sucks.
And, based on the sheer passage of calendar time, we have a generation of adults whose nostalgia has latched onto Flash. I've seen many a thinkpiece lately, waxing rhapsodic about the Flash era of the web. I'd hesitate to project a broad cultural trend from that, but we're roughly about the right time in the technology cycle that I'd expect people to start getting real nostalgic for Flash. And I'll be honest: Flash enabled some interesting projects.
In the great olden times, when Classic ASP was just ASP, there were a surprising number of intranet applications built in it. Since ASP code ran on the server, you frequently needed JavaScript to run on the client side, and so many applications would mix the two- generating JavaScript from ASP. This lead to a lot of home-grown frameworks that were wobbly at best.
Years ago, Melinda inherited one such application from a 3rd party supplier.