Skip to content

Use Booleans wisely

We often encounter cases where Booleans seem to be a natural choice

" anti-pattern
is_archived = abap_true.

until a change of viewpoint suggests we should have chosen an enumeration

archiving_status = /clean/archivation_status=>archiving_in_process.

Generally, Booleans are a bad choice to distinguish types of things because you will nearly always encounter cases that are not exclusively one or the other

assert_true( xsdbool( document->is_archived( ) = abap_true AND
                      document->is_partially_archived( ) = abap_true ) ).

Split method instead of Boolean input parameter moreover explains why you should always challenge Boolean parameters.

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