Sarah Savage logo

A fusion of development and business

The danger of boolean flags in object methods

Developers like to use booleans as flags. They’re a convenient way to indicate something as on/off, true/false, yes/no. But the problem is that booleans are not clear from calling code exactly what they do. For example: Does anyone in the calling scope have any idea what the defining scope is doing? Absolutely not. The flag could be set for saving the name in the database, or for making it all capital letters, or for echoing… continue reading.