This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design pattern for handling multiple String inputs

 
Elchin Asgarli
Ranch Hand
Posts: 222
Chrome Eclipse IDE Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a code similar to following:


This code honestly speaking looks a bit ugly to me, so I was thinking of the ways to refactor it. I do have few ideas of refactoring this, however before reinventing wheel, I wanna to know if there is already any design pattern made to solve such situation. The problem seems common enough to me, so is there a common pattern to refactor it? Did anyone have an experience with such situations?
 
Ramon Anger
Ranch Hand
Posts: 56
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Elchin,

this topic has been discussed here several times.
See for instance http://www.coderanch.com/t/99377/patterns/Chained-if-else-statements-avoid

Best regards,
Ramon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic