[Tutor] code smells: Object-orientation Abusers: switch statements

Alex Kleider akleider at sonic.net
Sat Jan 4 21:11:51 CET 2014


Continuing to look into the subject of code smells, I ran across this:
"The situation where switch statements or type codes are needed should 
be handled by creating subclasses."
@ http://www.soberit.hut.fi/mmantyla/BadCodeSmellsTaxonomy.htm

Assuming I am correct that in Python, switch statements must be 
implemented as a series of if; elif; .. statements, how is it that this 
can be avoided by creating subclasses?
tks
alex



More information about the Tutor mailing list