Clean Code: Dont use if’s! Use polymorphism instead

Writing clean code is crucial, so the software developer constantly needs to improve his skills and code understanding.

My way to do it, is to explore others’ best practices. Here is one of them to consider:

I am not fully convinced that all the if‘s shall be refactored and removed, however the example given is much cleaner with polymorphism. Moreover it is testable and deprived of code smells and arguments of this guy seems to be reasonable.

You may also want visit the Anti if campaign page :) – Thanks Maciek!

One thought on “Clean Code: Dont use if’s! Use polymorphism instead

Give Your feedback: