Java Refactoring - Replace Conditional with Polymorphism -
i made research refactoring college code. used jdeodorant plugin eclipse , throws me away, that:
if (object instanceof class1) { do_something1(); } else if (object instanceof class2) { do_something2(); } else if (object instanceof class3) { do_something3(); }
should replaced polymorphism. fine, except methods do_something() refer operations not related object. me polymorphism not work.
is there other way avoid using instanceof , seems unprofessional.
thank much.
Comments
Post a Comment