Is instanceof considered bad practice? If so, under what circumstances is instanceof still preferabl

Posted by aioobe on Stack Overflow See other posts from Stack Overflow or by aioobe
Published on 2010-05-01T16:37:57Z Indexed on 2010/05/01 16:47 UTC
Read the original article Hit count: 425

Over the years, I've tried to avoid instanceof whenever possible. Using polymorphism or the visitor pattern where applicable. I suppose it simply eases maintenance in some situations... Are there any other drawbacks that one should be aware of?

I do however see it here and there in the Java libraries so I suppose it has its place? Under what circumstances is it preferable? Is it ever unavoidable?

© Stack Overflow or respective owner

Related posts about java

Related posts about instanceof