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

‘So unchanged it is almost otherworldly’: the oasis town of Skoura, Morocco | Morocco holidays

The first thing I notice when I walk into the oasis is the temperature drop. Then, I hear the birdsong and the rustling of...

Have a good one, either way I guess. – The Bloggess

Today when we were finishing lunch the waiter was like, “How was your day?” and I said, “Good, thanks! A little exhausting, but...

The Best Coach Bags | PS Fashion

- Additional reporting by Balim TezelKyley Warren (she/her) is an award-winning writer and editor with more than four years of experience in the publishing...

Analog(ue) #194: One of the Best Whims I’ve Ever Had

#194: One of the Best Whims I've Ever Had October 10th, 2021 · 110 minutes This one is a big one! Almost too much to even put in...

How Y Combinator Started

March 2012Y Combinator's 7th birthday was March 11. As usual we were so busy we didn't notice till a few days after. ...