DEV Community

Discussion on: 5 easy wins to refactor even the ugliest code

Collapse
 
mlevkov profile image
Mikhail Levkovsky

Good point, for sure a switch statement should have a default.
I didn't include it in this case for brevity, and this is just an example. For something slightly more evolved I would actually resort to the factory pattern to create my return types and simplify the creation logic even more