Codemanship's Code Smell Of The Week - Switch Statements
Codemanship's Code Smell Of The Week - Switch Statements
Submitted by jason@parlezuml.com (Jason Gorman) on Fri, 16/07/2010 - 15:21.Switch 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).
Part I
Jason Gorman demonstrates how he refactors a simple switch statement into a polymorphic OO solution (like the Strategy Pattern).
Part I
