Apiumtech Apiumtech Apiumtech Apiumtech
  • ABOUT US
    • CAREERS TEAM
    • PARTNERS
  • SERVICES
    • WEB & MOBILE APP DEVELOPMENT
    • IT TRAINING & CONSULTANCY
    • SOFTWARE ARCHITECTURE
    • UX DESIGN
    • SPRINT ZERO
  • PROJECTS
  • BLOG
  • CONTACT US
Apiumtech Apiumtech
  • ABOUT US
    • CAREERS TEAM
    • PARTNERS
  • SERVICES
    • WEB & MOBILE APP DEVELOPMENT
    • IT TRAINING & CONSULTANCY
    • SOFTWARE ARCHITECTURE
    • UX DESIGN
    • SPRINT ZERO
  • PROJECTS
  • BLOG
  • CONTACT US
Apr 20

Refactoring: Replace IF by polymorfism

  • 04/20/2015
  • Xavi Hidalgo apiumteches
  • No Comments
  • Agile web and app development
  • Agile methodology, Refactoring

Kevin told me he found a funny page on a recurring theme in refactoring. As Uncle Bob said in his “Code Smells” when you see a code that have conditionals or too many “ifs”… is that there is something wrong … One of the keys to refactor is to replace the IF by polymorphism.

 

Screen-Shot-2015-05-01-at-10.59.53-AM-1024x361

REFACTORING

When we want to refactor, we should always refactor by design patterns, knowing what we do …

I use to come back to the Martin Fowler RefactoringCatalog

We found that refactoring is an aggressive process which virtually hurts the keyboard exercising all the shortcuts of our IDE.

Specifying the substitution of conditionals

As Fowler says: “When you have a conditional that chooses between different behaviors depending on the type of an object” … That can be changed easily info classes.

There are other places to give more extensive explanations if you prefer:

  • RefactoringGuru
  • SourceMaking

 

Finally, I recommend checking out this great site where refactoring conditional is explained in a way… let’s say different. 🙂

  • Facebook
  • Twitter
  • Reddit
  • Pinterest
  • Google+
  • LinkedIn
  • E-Mail

About The Author

Related Posts

  • Agile working without borders01/21/2016
  • 15 benefits of software architecture01/11/2016
  • Agile methodology is not only for software development01/04/2016
  • Top benefits of continuous integration12/28/2015

Leave a reply

You must be logged in to post a comment.

JOIN OUR NEWSLETTER

Receive our publication right in your email.





Sending ...

Categories

  • Agile web and app development
  • Apiumtech
  • Events
  • Jobs
  • Offshoring and outsourcing
  • Software architecture
  • Technology industry trends
  • Uncategorized
  • User Experience Design
apiumtech.com Apiumtech is an agile software development company offering services of software architecture, web development, mobile app development, IT consulting, user experience design, bigdata and blockchain

LATEST NEWS

  • Hello world!
  • User experience design infographic
  • Apiumtech’s monthly Newsletter
  • 8 Digital marketing trends in 2016

JOIN OUR NEWSLETTER

    CONTACT INFO

    Av. Doctor Mitjavila 5
    AD500 Andorra la Vella
    Principat d’Andorra
    (+376) 692 2881
    info@apiumtech.com
    © 2022 APIUMTECH SLU. ALL RIGHTS RESERVED.