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

Heresy

April 2022One of the most surprising things I've witnessed in my lifetime is the rebirth of the concept of heresy.In his excellent biography of Newton,...

Reckless brother demands sister co-sign on new luxury car after driving himself to bankruptcy: ‘I’m scared he’ll ruin my good credit. I have my...

Family and finances… finances AND family! The ultimate recipe for awkward conversations, simmering resentment, and the occasional shouting match. You really need to be a...

Primark launches clothing range designed for people with disabilities | Fashion

It’s a go-to shop for cheap knickers and designer dupes, but now Primark hopes to become the top destination for clothing designed for those...

Westman Atelier Petal Collection 2025

Westman Atelier launched her Petal Collection for spring and it’s beautiful! The Petal Baby Cheeks Blush Stick ($48) has been a staple for me...

Best Clothing Subscription Boxes for 2025

CNET’s expert staff reviews and rates dozens of new products and services each month, building on more than a...