Jul 27, 2024
I also don't like if-else especially for complicated conditionals, and switch statements in general become hard to read and maintain quickly.
But I would vomit if the solution is polymorphic classes in a codebase where I worked, and I wouldn't stay there.
Guard clauses with more small, easy-to-understand helper functions -- and/or state machines to make branching logic easy to visualize and understand -- would seem far superior to that nonsense.