Practical Programming Example

Refactoring Your Switch to Ad-Hoc Polymorphism for Better Code Quality

You’ll rarely ever need to branch on a discrete value.

Nicklas Millard
Published in
5 min readOct 30, 2021

--

Image by Nicklas Millard

I’ve mentioned this a tonne already, and this won’t be my last, but branching on discrete values using switch cases and if-else statements is often a terrible idea.

--

--

I mostly write to "future me" sharing what I learn and my opinion on software development practices. youtube.com/@nmillard | open for contracts in Jan 2026.