Time For (a cool change)

by in Error'd on

Without much ado, five minidoozies follow.

If it isn't one thing it's another, for our regular Argle Bargle. "I looked outside. Everything was soggy and I could hear claps of thunder. How long will it last? Click on weather and... um... Fire Weather? I can think of only one way I'm getting a fire going in my backyard right now and it involves a flamethrower." It's better than tornadoes!


Exceptional Messages

by in CodeSOD on

Structured exception handling is an excellent way to handle errors, but wouldn't it be nice if you could execute a different branch of code depending on what specific error just happened? It's a pity that there's just no possible way to filter exceptions using the good old fashioned try and catch. Fortunately, Mateusz has a co-worker who invented that wheel for us.

if (something_bad_happens)
        throw new Exception("File is not correct; 88888");

if (something_else_happens)
        throw new Exception("Tag len exceeded; 1337"); 
...

catch (Exception ex)
{
    if (ex.Message.Contains("88888"))
    {
                ...
    }
    else if (ex.Message.Contains("1337"))
    {
            ...
    }      
}

Closely Related

by in CodeSOD on

Relational databases were at one time an absolute standard that nearly any developer could be expected to be familiar with. These days, it's still valuable knowledge, but it's less surprising when someone doesn't know more than the basics- there are so many other ways one might persist data, each with their own tradeoffs. But if someone is developer for a contracting firm specializing in data driven applications, you would expect them to have a little more grounding in RDBMSes than the average developer. Well, you would expect that if you thought the contracting firm was actually selling a valuable service, instead of trying to bilk their customers and their contractors and hope nobody notices.

The important things about RDBMSes is that each table represents a relation- a set of fields that are all conceptually related, like "Employee" (with an employee ID, a name, a hire date, etc.) or "SalesListing" (with a product description, a price, etc.), and then those tables can have relationships to other tables- foreign keys that guarantee that if "SalesListing" has a "SalesRep" field on it, that "SalesRep" has a matching entry in the "Employee" table.


An Accountable Service

by in CodeSOD on

While the world has switched to RESTful APIs, the magical power of SOAP-based web-services was that they made code generation easy. Well, easy-ish. Well, easy when it worked right, and then hard the rest of the time. But if it worked, if the WSDL was up to date and sane, you'd get a nice client-side API to invoke methods on the remote server.

Andrew inherited one such client-side C# API. It looked something like this:


Time Changes

by in CodeSOD on

Dates and times are way more complicated than we usually think they are, especially when we're talking about historical dates and times. The solution, of course, is to always use someone else's work, whether it's a library or your language's built-ins, never implement date handling yourself.

For a long time, though, Java's date handling left something to be desired. Which is why Sven found this history lesson in his company's code base:


Phoning One In

by in Error'd on

Many years ago, at the height of the Industrial Revolution, the United States was criscrossed by a riot of regional railroads. Gradually, these were acquired or merged until now there are only about a half-dozen major national railroads. In a similar fashion, at the birth of the public Internet, there must have been thousands of community Internet service providers. It seemed like every town had its own entrepeneurial enterprise, with some racks of modems in an office somewhere. Those quickly got snapped up or forced into bankruptcy, as legacy cable telecoms companies leveraged their existing monopolies into a new line of business. Which brings us to this week's Error'd. Enjoy(?) it.

First up, Adrian McCarthy grumbles "Getting help can be difficult when your regional monopoly internet service provider cannot assemble a functional web site. Note that the understandably required Description field in this online support contact form is disabled."


Tied to the Train Tracks

by in CodeSOD on

Ah, the joys of stringly typed code. Everything can be turned into a string, so why not treat everything as a string? It certainly worked for Sebastian's co-worker, who also took it to another level:

If GetTrainAtStation(aTrainNo.ToString) Is Nothing Then
    iTheTrainAtStation.Add(String.Format("{0}", aTrainNo.ToString), aTrainAtStationItem)
End If

All in the Timing

by in CodeSOD on

We like using constants instead of magic numbers. Today, we see an unusual misuse of them. It's unusual because, while it's a set of bad choices, it's not quite a `#define ONE 1` level of silliness.

First, a little background. Benjamin inherited a building automation system. This building automation system was implemented in Microsoft's Visual C++, version 6.0, way back in the 90s. As of the late 2010s, not only was it still in use, it was still pinned to the same compiler version. So not exactly the most modern of applications, but it accomplished the business goals, albeit with a lot of bugs, errors, and mysterious glitches.


Archives