Code Smell 62 — Flag Variables
Flags indicate what happened. Unless their name is too generic.
- Use meaningful names
- Try to avoid flags. They generate coupling.
We can search all the code for bad named flags.
Flags are widespread on production code. We should restrict their usage and use clear and intention revealing names.
Code Smell 51 — Double Negatives
Not operator is our friend. Not not operator is not our friend
Code Smell 07 — Boolean Variables
Using boolean variables as flag, exposes accidental implementation and pollutes the code with Ifs.
A boolean flag, truth bit or truth flag in computer science is a Boolean value represented as one bit A single byte can…
If you lie to the compiler, it will get its revenge.
This article is part of the CodeSmell Series.