As a fresh dev, I’d like to know the answer to this as well. Abstract to function w multiple params, abstract to multiple functions, no abstraction and keep as switch statement.
`print_table() + print_table_without_emoji()`
vs
`print_table(remove_emoji= False)`
vs
`switch table_name:
case emoji:
print(table)
case no_emoji:
print(table no emoji)`
If callers typically know statically whether they want emoji or not (in other words, if the parameter would typically be a literal true or false at the call site), then the parameterless version is better. (Note that you can still factor out common code from the two functions into a separate private function if you like. So the parameterless version doesn’t necessarily imply code duplication.) If, on the other hand, callers tend to be parameterized themselves on whether to use emojis or not, then the parameterized version is better, because it avoids having to make a case distinction at the call site.
It depends on the implementation, but in general you prefer the parameterless version because in theory a bug that shows up in print_table has less code it could be in (less surface area to debug).
Without understanding the implementation no one can truly say which is the better approach, but this idea of "surface area for bugs" is something that should be considered when approaching these types of decisions.
`print_table() + print_table_without_emoji()`
vs
`print_table(remove_emoji= False)`
vs
`switch table_name: case emoji: print(table) case no_emoji: print(table no emoji)`