1 Comment
User's avatar
⭠ Return to thread
Mirza Abazovic's avatar

IMO "Instead of booleans, use Enums, making your code self-documenting."is

use two functions with descriptive names (follow the rule 2).

Usually when You have boolean as param in function You have inside "if" and if You replace it with enum logic will stay (some kind of "if")

By dividing into two functions

It will make your function logic simpler and function will be more SRP, and you will avoid complexity in function.

It helps with rule 1 - keep them smaller.

Of course follow also DRY for code that is the same in two new functions (maybe there is a smaller third one function inside)

Expand full comment