Skip to content

Try to make conditions positive

IF has_entries = abap_true.

For comparison, see how hard to understand the same statement gets by reversing it:

" anti-pattern
IF has_no_entries = abap_false.

The “try” in the section title means you shouldn’t force this up to the point where you end up with something like empty IF branches:

" anti-pattern
IF has_entries = abap_true.
ELSE.
  " only do something in the ELSE block, IF remains empty
ENDIF.

Read more in Chapter 17: Smells and Heuristics: G29: Avoid Negative Conditionals of Robert C. Martin’s Clean Code.

From SAP/styleguides under CC BY 3.0 — more details
Last updated on