← Graph

Boolean Flags as Implicit State

concept 2 connections

Anti-pattern where an object's state is encoded across several boolean flags (on_boarded, trial_expired, can_use, subscription_cancelled, subscription_expired, etc.). N binary flags produce 2^N combinations, most invalid or never considered, causing 'combinatorial complexity explosion'. Hidden forms of flags include dates, periods, presence/absence of associations, and status fields. The fix is to make the implicit state explicit via a state machine — system behavior then depends on a single known state rather than ad-hoc flag combinations. Gems like flag_shih_tzu merely standardize the anti-pattern and should not be used for managing state.

category
practice
about
Boolean Flags as Implicit State concept
Critiques boolean flags as an implicit-state anti-pattern leading to 2^N combinations.
concept Boolean Flags as Implicit State
related_to
State Machine concept
State machines are the explicit alternative to implicit boolean flag states.

Provenance

Read by
11 extractions