I am looking over some code that has heavy use of Java's instanceof
operator. I will fight the temptation to go into details, since this is a general question. instanceof
reminds me of of c++'s dynamic cast, and the advice I read about it, long ago, that if you think you need it, probably your model is off. Is this still the conventional wisdom? Does it apply to Java's instanceof
?
Yes, you are on the right track. While instanceof
certainly has its uses, heavy use generally indicates that your class design is deficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With