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

23 03 2013

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!

Do you like my blog?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality

Donate Button with Credit Cards

Thank You!



One response

30 03 2013
Clean code: Error-proof and testable code | Looks OK!

[…] the previous post, here is another video. This one is lot more packed with concepts and best practices, so it is […]

Give Your feedback:

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: