I was a little careless the other day, I lost one of my business objects in a Collection ! Or to be more precise a Java business object that I had placed in a Set could only be found by iterating through the contents of the Set, if I asked the contains(Object) method to find the object that I just added but it couldn't find it. Now the clue that I should have spotted sooner was that the rather plain add(Object) method I was calling was in fact on another application class and not directly on the Set. What was happening was this other add(Object) was adding the object to the Set and then was adding the Set into the business object (it was doing this correctly as we wanted a parent-child relationship so that each knew about the other). The problem was that the hashCode method of the business object used it's reference to the Set to compute it's value. When the object was added to the Set hashCode produced one value, once the Set was linked to the object, hashCode prod
eng mgr / leader / full stack / java / agile / tdd / security / aws / go