conditional to polymorphism

A conditional, like a switch statement can sometimes be fraudulent. It appears to be a nice and simple solution when it is in fact hiding and provoking duplication. By refactoring to polymorphism we adhere to the ‘Tell Don’t Ask’ principle and get rid of the duplicated parts.

the code on my GitHub

Comments