Flags - Good or Bad?

Is the use of boolean flags to determine the flow of a program an acceptable technique, or is it generally deemed 'hackey' in nature with the propensity to lead to messy code? I ask because using flags somehow feels wrong, almost like using goto as a quick fix, yet at the same time they can provide a very simple solution when establishing what processes will come into effect at certain points in the program.
Last edited on
I don't know about others but I find it pretty useful...
It is contextual.
Using a few bools is fine.
If you feel the urge to have 4 or more bools, you're better off with bitmasks.
Use switches instead of multiple if/else, when possible.
Flags are neither good nor bad. It depends on how you use them.

Is the use of boolean flags to determine the flow of a program an acceptable technique
Yes.

is it generally deemed 'hackey' in nature with the propensity to lead to messy code?
No.

I ask because using flags somehow feels wrong
Maybe that means you're doing something wrong with flags?

at the same time they can provide a very simple solution when establishing what processes will come into effect at certain points in the program.
Simplicity is good.
Okay, thanks guys. I guess the answer is that it depends on how you use them.
Topic archived. No new replies allowed.