CodeSOD: A Monthly Addition

Date:

Share:

In the ancient times of the late 90s, Bert worked for a software solutions company. It was the kind of company that other companies hired to do software for them, releasing custom applications for each client. Well, "each" client implies more than one client, but in this company's case, they only had one reliable client.

One day, the client said, "Hey, we have an application we built to handle scheduling helpdesk workers. Can you take a look at it and fix some problems we've got?" Bert's employer said, "Sure, no problem."

Bert was handed an Excel file, loaded with VBA macros. In the first test, Bert tried to schedule 5 different workers for their shifts, only to find that resolving the schedule and generating output took an hour and a half. Turns out, "being too slow to use" was the main problem the client had.

Digging in, Bert found code like this:

IF X = 0 THEN Y = 1
ELSE IF X = 1 THEN Y = 2
ELSE IF X = 2 THEN Y = 3
ELSE IF X = 3 THEN Y = 4
ELSE IF X = 4 THEN Y = 5
ELSE IF X = 5 THEN Y = 6
ELSE IF X = 6 THEN Y = 7
ELSE IF X = 7 THEN Y = 8
ELSE IF X = 8 THEN Y = 9
ELSE IF X = 9 THEN Y = 10
ELSE IF X = 10 THEN Y = 11
ELSE IF X = 11 THEN Y = 12
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF

Clearly it's to convert zero-indexed months into one-indexed months. This, you may note, could be replaced with Y = X + 1 and a single boundary check. I hope a boundary check is elsewhere in this code. because otherwise this code may have problems in the future. Well, it has problems in the present, but it will have problems in the future too.

Bert tried to explain to his boss that this was the wrong tool for the job, that he was the wrong person to write scheduling software (which can get fiendishly complicated), and the base implementation was so bad it'd likely be easier to just junk it.

The boss replied that they were going to keep this customer happy to keep money rolling in.

For the next few weeks, Bert did his best. He managed to cut the scheduling run time down to 30 minutes. This was a significant enough improvement that the boss could go back to the client and say, "Job done," though it was not significant enough, so no one ever actually used the program. The whole thing was abandoned.

Some time later, Bert found out that the client had wanted to stop paying for custom software solutions, and had drafted one of their new hires, fresh out of school, into writing software. The new hire did not have a programming background, but instead was part of their accounting team.

[Advertisement]
Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.

Source link

Subscribe to our magazine

━ more like this

DDoS Botnet Aisuru Blankets US ISPs in Record DDoS – Krebs on Security

The world’s largest and most disruptive botnet is now drawing a majority of its firepower from compromised Internet-of-Things (IoT) devices hosted on U.S. Internet...

Apologies to the people who saw me sobbing as I left the doctor. Emotions are weird af. I’m totally fine. (And itchy.) – The...

So about 6 months ago I started having this itching inside one ear that kept getting worse and nothing fixed it so I went...

What To Wear To Austin City Limits Music Festival 2025

I've never been much of a festival girlie. It's not because I don't love live music (I do); Between big crowds (I'm barely 5'2 and...

Noyz Only Human Fragrance Gourmand Perfume Review

Notes of vanilla bean, ambroxan, and cedarwood blend with invigorating pink pepper, bergamot, and lily to create a scent that's complex, addictive, and perfect...

You Can Now Hide Sponsored Ads in Google Search

Did you know you can customize Google to...