Member-only story
The Many Faces of “If” and How Programmers Misuse It
8 ways to use the conditional statement correctly
What would programming be without the conditional if statement? Probably one of the most used logic checkpoints in all of programming, we would be lost without it. Unfortunately, as simple as it is to add this decision point to your code, it is not immune to misuse. In my 20 years as a programmer, I have seen some interesting mistakes by other programmers. In no particular order, here are eight examples based on real-life problems with “if” and possible reasons for why they happened.
1) If/Else on a Boolean
The basics of an if statement is to proceed into a block of logic when a condition evaluates to true. A complementary feature is the boolean data type, which is used to indicate true or false. They are often used together, but in this example, they shouldn’t be. The if/else logic isn’t necessary and the boolean value alone is sufficient. Here’s an example:

