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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -