Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java equals()

Name: Anonymous 2009-05-18 5:38

I want to put an equals() method in all of mine immutable (final) classes.
Should I use the instanceof or the getClass() approach?

thanks!

Name: Anonymous 2009-05-18 18:40

>>17
It appears to take the atypical argument that because a square cannot do everything a rectangle can do it can't be a subclass. This is entirely false- namely because the premise is false and the scale(double x, double y) method is a good example of this. It's argued a rectangle would have such a method but a square cannot have such behavior because it would no longer be a square. What is wrong here is assuming any class of a rectangle when scaled is still that same class of a rectangle, not that the square can't satisfy the specified behavior. The solution would be a mutable Shape system, and then having scale return an object of type Shape or Rectangle- not simply attempt to transform a Square.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List