CodeSOD: Time Changes 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 ...
Error'd: Phoning One In 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, ...
CodeSOD: Tied to the Train Tracks 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
...
CodeSOD: All in the Timing 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 ...
CodeSOD: Magical Destruction Pretty much all object oriented languages have some concept of "destruction": objects need to release any resources they acquired at construction. In a lot of cases, we don't need to customize this terribly much, but when we do, it's vitally important to do it correctly.
Nancy's ...
Requirements in Technicolor Managing the requirements for an application is a huge challenge. The hardest part of the challenge is that, very frequently, the user's don't know what they really want or need. Prying it out of them, and giving them an application that actually solves the real problem they have, is an ...
Error'd: Filling We got quite a few irregular submissions this week from regular
contributors. Which is to say routine contributors. We're
not qualified to make judgements about whether or not anyone is what
what most folks would call normal.
First up,
Isaac D. is struggling with ...
CodeSOD: The Properties of Contract Development James's management had more work than they had staffing for, so they did what any company would do in that situation: expand their staff. No, of course not, I'm kidding. They bundled up a pile of work and shipped it off to the contractor who gave them the lowest bid, provided absolutely no ...
CodeSOD: Going to Great Len(gths) Mira was trawling through some old Python code. This particular block of code needed to load some data from JSON. The data was an array, and the code needed to know how long the array was.
Python has a handy len function that does this on anything enumerable. If our developer had used len, we'd ...
CodeSOD: Terning On a Control One of Tim's co-workers needed to handle a simple condition: if a control in their web app was enabled, show it, otherwise hide it.
Now, if you or I were writing that, we might write some awfully verbose code, like:
if (on)
{
d.show();
}
else
{
d.hide();
}
It's an obvious solution, and ...
CodeSOD: A False Comparison Iterating across a list is a very simple task. It's a CS-101 type thing, and if anything, it's the one thing I'd expect any developer to be able to do without confusing me too much.
Brendan has a co-worker that wants to change my mind about this.
They write Java code like this:
if ...
Error'd: Nothin Doin IBM Profs was introduced in 1980 including both email and calendaring support. Online
calendaring is now old enough to have grandchildren, but we still can't
get the simplest things right.
As our friend
Romeo
rhetorically wonders "Million dollar question: What calendar does Microsoft ...
CodeSOD: Evaluating Selections If you're writing an application with a drop-down list, it's typical and reasonable to auto-select a certain option in the list. But John found an approach to doing this that's anything but typical.
function selectsearch(myform, myselect, myinput) {
var i = 0;
var fvalue = 1;
...
Tales from the Interview: The Final Interview Gennifer had a job. Her employer got bought out by another company, and the purchaser was notorious for gobbling up companies, taking over their processes, and then doing mass layoffs. Seeing the writing on the wall, Gennifer started job hunting.
Before too long, she had two very likely candidates. ...
CodeSOD: Trying Parses Another day, another terrible way to validate integers. Today's submission comes from Sluiper.
This approach, at least, contains a mild bit of cleverness. It's not the good kind of cleverness that makes a complicated problem more clear and easier to understand, but the bad kind that ...