Sunday, August 15, 2004

Don't use instanceof

"Anytime you find yourself writing code of the form "if the object is of type T1, then do something, but if it's of type T2, then do something else," slap yourself."

That includes equals (unless you want to inherit equality across an interface - I tend to use casting anyway).
Post a Comment