July 16, 2010
Codemanship's Code Smell Of The Week - Switch StatementsSwitch statements are bad from an OO design standpoint. Not only because they're basically big nested IF statements, but because they have a tendency to grow. A refactored switch statement would exploit polymorphism, which is the OO way to make decisions about how to do specific "stuff" at run time.
Jason Gorman demonstrates how he refactors a simple switch statement into a polymorphic OO solution (like the Strategy Pattern).
Download the source from http://bit.ly/8Y71ik
For training and coaching in refactoring, OO design and TDD, visit http://www.codemanship.com
Posted 8 years, 11 months ago on July 16, 2010