|
"equals-but-no-hash" and "rehash" are gross hacks and should not be taken seriously. For me, the underlying pattern to follow is: "Define (maybe context-dependent) the point in an object's lifetime, after which it is illegal to alter those fields that make up the object's "value-identity" (as implemented by #equals/#hashcode). At that point your object has "settled" on its identity. Only after this point, it's ok to put this object into a hash structure."
A software that violates this rule is not sound. It's not just about hashing. The semantics are broken. The above definition gives you a number of interpretations about the when's, how's and who's of enforcing it. |