Replace Conditional with Visitor

Refactoring contributed by Ivan Mitrovic

You have an "aggressive" Conditional that chooses different behaviour depending on the type of an object and repeats itself in a large number throughout the code.

Create concrete instance of Visitable object for each data type in Conditional. Create concrete instance of Visitor that encapsulates logic of each Conditional. Visit Visitable by Visitor.

More Information

| Refactoring Home | | Alphabetical List |