Strategy Design Pattern applied to hashCode() and equals()

The latest issue of the JavaSpecialists newsletter (by Dr. Heinz Kabutz) features a lengthy look at possibility of applying the Strategy design pattern to the equals() and hashCode() methods commonly used in Java. In it he concludes that the equals and hashCode methods autogenerated by IntelliJ Idea are better from a performance standpoint.

If your IDE of choice doesn’t include the ability to autogenerate the bodies of the above mentioned methods, you might also check out the EqualsBuilder, HashCodeBuilder and ToStringBuilder classes in the Jakarta Commons Lang library.

One thought on “Strategy Design Pattern applied to hashCode() and equals()”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>