Avoid double negative logic

Conditional logic should avoid double negatives. e.g., "Is this not not true?"

Why

  • Double negatives are hard to comprehend.

How

  • Write logic that asks: Is this true. Instead of: Is this not not true?

Example

A double negative conditional, which is hard to understand:

if (!isNotSelected) {
    ...

Then written in the positive:

if (isSelected) {
   ...

References