DEV Community

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

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

I like the approach of coalescing a huge nest of if statements into a map lookup - it makes the code easier to read and understand! Like anything, though, you can overdo it - it doesn't help much for a 2-choice branch, and may use more resources than a simple if/else would have. Thanks for sharing!

Collapse
 
tomazfernandes profile image
Tomaz Lemos

Hi Eric! I’m glad you liked it, I like it a lot too! I’m in need of feedback for this other pattern, if you could take a look I’d really appreciate hearing your thoughts 😃

dev.to/tomazlemos/implementing-a-s...

Thanks for your kind reply, and Happy New Year!

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

Done, glad to know it's useful.

Thread Thread
 
tomazfernandes profile image
Tomaz Lemos

Super useful Eric, thank you very much!

Collapse
 
tomazfernandes profile image
Tomaz Lemos

I decided to rewrite that post based on your and other fellow DEV's feedback, if you'd care to read the new version I'd really appreciate!

dev.to/tomazlemos/let-s-talk-trade...

Collapse
 
wrldwzrd89 profile image
Eric Ahnell

Done. This is why DEV is great - we help each other get better!

Thread Thread
 
tomazfernandes profile image
Tomaz Lemos

Thanks a lot Eric!