On 5/17/10 1:44 PM, Felix Knecht wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
IMO, writing a decent HashCode() method is simple. No need to use this
HashCodeBuilder that don't lnow how to deal with Object (it simply add
the object.hashcode() to the computed hash code, which is bad).
I don't see whats bad doing so. The rule is "if two objects are equal,
then their hashCode values must be equal as well". As a very bad
solution we can just return 1111 in every case :(
It's bad as it carries the semantic, not the logic. In other words, ypu
may have two objects considered as different when they are equals, just
because you were too lazzy to implement the hashcode method. I give you
an example : comparing two Entry instance in the server is just about
comparing their DN, nothing else. If you call the HashcodeBuilder on it,
you will get errors if the Attributes are the same, but stored in a
different order, which is not expected.
Of course, this is a case by case issue.
What I mean here is that hashcode computation must be contextual.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.nextury.com