DEV Community

Discussion on: Keeping your code clean by sweeping out "if" statements

Collapse
 
mindplay profile image
Rasmus Schultz • Edited

In my opinion, now you have the mental burden of both approaches.

Personally, I'd want to choose one.

In my point of view, if you have to have a couple of if-statements before checking the map, that's a sure sign that the map is the wrong abstraction - for example, maybe the type inside the map is the wrong type and you may need to consider adding more abstraction, e.g. a type that covers all your cases; again, being aware of the complexity trade-off.

Maybe it's worth it, maybe it isn't. This is where the job gets hard 😉