DEV Community

Discussion on: Why Switch Statement is Bad

Collapse
aghost7 profile image
Jonathan Boudreau

I find that switch statements are nice for things like enums. The values are limited so the API can still be kept clear. I think the main issue with your example is with stringly-based API (status is a string) being used in a statically typed language. Its not necessarily that you're using a switch statement.

Collapse
eslamelkholy profile image
eslamelkholy Author

Yea Switch statement is cool but sometimes when new requirements comes up the code maintenance is going to be very hard by time so by adding new features as you mentioned new Enum for example you just need to add new class it's better than editing in the switch statement it self