Is using flags really that bad? Especially for large complex functions? Not using them would mean that I need two (large) functions instead of having one simple switch. I would imagine this often leads to problems because stuff is fixed inside one function but not the other.
Yeah, there are cases when it should be done and the cases where it should not. The example in the article is an obvious example when it should not be used though.
The issue is with description of the case. It should've say something along the lines of "boolean flags in function arguments should not change the function's core logic, only its side effects".
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is using flags really that bad? Especially for large complex functions? Not using them would mean that I need two (large) functions instead of having one simple switch. I would imagine this often leads to problems because stuff is fixed inside one function but not the other.
Agreed. It’s easily avoided in the article’s example, a one-line function. But flags can help us write DRY code for more complex functions.
Yeah, there are cases when it should be done and the cases where it should not. The example in the article is an obvious example when it should not be used though.
The issue is with description of the case. It should've say something along the lines of "boolean flags in function arguments should not change the function's core logic, only its side effects".