As always, it started with a bug. We’d been extending the capabilities
of one of our services, to allow filtering deals on a new concept. While
introducing that new concept, some classes had new fields added. One of those
classes implemented equals()
, but the method wasn’t updated to account for
the new field.
The first-order fix was easy: just re-generate the equals()
method. Trying to
protect against this class of problem reoccurring, though, is a really
interesting question.
Not because it’s difficult to come up with a broader solution, but because
so many solutions are available. And they’re all terrible in different ways.
But first, let’s talk about equals()
, and understand our problem.