re: What is your pettiest programming-related opinion? VIEW POST

re: swtich statements have no real use case that could not be implemented using other simpler features of the language.

I will die on this hill with you. Back to back, mini gun aiming down the hill, mowing down anything that comes our way except food delivery.


have you ever had a legit use case for switch?

I mean I think in finite lists they can have some application. Think like cardinal directions(Noth, East, South, West), basically TRUE Enums, absolutely finite ones. They can be useful sometimes in those cases. You could in theory use a strategy pattern or something even then, and be a more robust solution but it could be seen as over-engineering. If you MUST use one or have a case like above, I always like to throw an exception in the default case. If it shouldn't occur and does, I for sure want to know about it, and I don't want something weak like it being logged. I want it to be a mini-crisis.

code of conduct - report abuse