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

The Four Quadrants of Conformism

July 2020One of the most revealing ways to classify people is by the degree and aggressiveness of their conformism. Imagine a Cartesian coordinate system whose horizontal...

Dark Matter – PostSecret

For twenty years, PostSecret has broadcast suburban America’s hidden truths—and revealed the limits of limitless disclosure. — Meg Bernhard In the early aughts, Frank Warren ran...

Megan Fox’s Pink Cherub Nails Are a Nod to Her New Baby

While each product featured is independently selected by our editors, we may include paid promotion. If you buy something through our links, we may...

638: Hop, Hop, Hop

Pre-show: Chromebook-block evasions Follow-up: At least one person did miss our WWDC sale. 🙁 Vision Pro Corner: StagePlay Blue Man Group Epic vs. Apple The Verge on Apple’s decision making Apple’s...

Colin from Accounts stars confirm season 3 will begin with a time jump

However, speaking to RadioTimes.com on the red carpet for the 2025 BAFTA Television Awards with P&O Cruises,...