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.
02 Dec 2019
•
refactoring-java
Comments