DEV Community

Discussion on: 10 must-know patterns for writing clean code with Python🐍

Collapse
 
koljaoh profile image
koljaoh

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.

Collapse
 
bluemont profile image
Bluemont

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.

Collapse
 
potasiak profile image
Sebastian Potasiak

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".