Mark Lawrence <breamore...@yahoo.co.uk>: > http://c2.com/cgi/wiki?SwitchStatementsSmell
Your brief summary, please, Mark? Anyway, the first 1000 lines or so that I managed to read from that page stated a valid principle, which however doesn't invalidate the existence of a switch statement. A colleague of mine taught me decades back that the whole point of OO was the avoidance of if and switch statements. So if your code has an if or switch statement, chances are you are doing something wrong. I agree. However, like all other maxims, that principle, too, has exceptions. Two recurring examples are parsers/decoders and state machines. Sure, you can implement states beautifully with objects/classes (and I do do that when performance is not an issue), but having experimented with different implementation techniques (in C, C++ and Java), I have concluded that switch statements are often unbeatable in performance and clarity. And I sometimes run into convoluted factory (anti)patterns whose sole purpose is to avoid straightforward switch statements in a decoder. Marko -- https://mail.python.org/mailman/listinfo/python-list