Very true!

That's exactly what I'm on about here.

There're too many examples in the wild doing crazy nested if-else branching when it could have been handled elegantly with the State pattern.

I know this article will upset a lot of if-else fanboiz. That's kinda the purpose.

Refactoring to State pattern is just one way to remove if-else branching. There're many other ways, depending on the concrete situation and goal.

Software Developer Manager | Big4 ex. FinTech | Writer with +1M views. Sharing my opinion & what I learn. YT channel youtube.com/c/NicklasMillard

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store