Article 5YKP6 CodeSOD: Never Don't Stop Not Doing This

CodeSOD: Never Don't Stop Not Doing This

by
Remy Porter
from The Daily WTF on (#5YKP6)

It's not nothing to never write confusing English. And it doesn't never influence the code that we write. Don't fail to look at this anti-pattern from today's un-named submitter.

If Not port Is Nothing Then portUnAvailable = FalseEnd If

If the port isn't nothing, then the port isn't unavailable. That's... not untrue. But it is surprisingly confusing when you're reading it in a larger block of code. And, of course, this would be simpler to express as a boolean operation:

portUnAvailable = port is Nothing

Then again, without context, that might be wrong- perhaps portUnAvailable gets set elsewhere and then changes only if Not port Is Nothing. But let's assume that's not how this works, because that hints at a bigger WTF.

Do never don't avoid this pattern in your own code or writing.

proget-icon.png [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more. TheDailyWtf?d=yIl2AUoC8zA
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments