The Saddest Words: What If

Date:

Share:

Conditional statements, we would hope, are one of the most basic and well understood constructs in any programming language. Hope, of course, is for fools and suckers, so let’s take a look at a few short snippets.

Our first installment comes from Jonas.

if (!checkAndDelete(Definitions.DirectoryName, currentTime)); 

I appreciate the comment, which informs us that this empty statement is intentional. Why it’s intentional remains mysterious.

Jonas found this while going through linter warnings. After fixing this, there are only 25,000 more warnings to go.

Brodey has a similar construct, but from a very different language.

If (Session.Item(Session.SessionID & "Origional") IsNot Nothing) Then
End If

I have to give bonus points for the origional spelling of “original”. But spelling aside, there’s a hint of something sinister here- we’re concatenating strings with the SessionId– I don’t know what is going wrong here, but it’s definitely something.

Our last little snippet comes from Midiane. While not a conditional, it shows a misunderstanding of either booleans or comments.

$mail->SMTPAuth = false; // turn on SMTP authentication

The comment clearly is out of date with the code (which is the main reason we shouldn’t repeat what is in the code as a comment). At least, we hope the comment is just out of date. A worse scenario is that setting the flag equal to false enables it.

Source link

Subscribe to our magazine

━ more like this

He Chunhui’s Tiny386 Turns the Humble ESP32-S3 Into a Fully-Functional 386-Powered Desktop PC

Developer He Chunhui has turned the humble Espressif ESP32 microcontroller into a fully-fledged '90s personal computer with Tiny386 — a resource-efficient emulator capable of...

22 Pictures of Cats Cozying Up by the Fire and Living Their Fluffiest, Toastiest Lives

When the weather turns cold, cats somehow always discover the warmest, coziest corner of the house usually right by the fireplace. They curl up...

Under-$100 Free People Gifts For Everyone On Your List

It’s pretty safe to say that we’re all on a budget and all short on time. The solution? Free People’s online gift shop. The...

Today’s NYT Strands Hints, Answer and Help for Nov. 9 #616

Looking for the most recent Strands answer? Click here for our daily Strands hints, as well as our daily answers and hints for The New...

William Sealy Gosset Plaque in Ireland

When William Sealy Gosset joined the Guinness brewery in Dublin in 1899 as a chemist, he faced a practical problem: how could he...