This content has been marked as final. Show 2 replies
I would recommend Command pattern but it also depends of the nature of work the if else blocks are doing.
More generally it is acknowledged that you can replace "if" with inheritance (polymorphism). I think [this article|http://sourcemaking.com/refactoring/replace-conditional-with-polymorphism] describes it well, with code examples.
Several well-known patterns leverage this (State, Strategy, Command,... oh, and yes, Visitor too).
P.S.: Please clarify your question. The previous poster replied to the question implied by the title of your post. But the text of your post implies you have a question specific to the Visitor pattern.
Edited by: jduprez on Aug 13, 2010 9:31 PM