Joshua Vanrenterghem wrote:Sure, there is a small educational benefit for the reader to see the exact steps it takes to get code from text to a program, but after one time this should be completely understood.
Mike Simmons wrote:The JLS officially defines it as a resource specification. The Java tutorial on the other hand doesn't define anything, but it talks about how it "declares resources". I would say resource specification, resource declaration, or resource list are all decent names for this, pretty clear. It's a try-with-resources statement; these are the resources.
Stephan van Hulst wrote:assuming you wrote parameterized tests to begin with
Stephan van Hulst wrote:No. Tests must be simple and test one specific thing.
Stephan van Hulst wrote:Classes are either value types in which case they have a definition of equality that is based on all normalized fields, or they are entities or services, in which case different instances are unequal.
Stephan van Hulst wrote:Why was the field allowed to be null? This should occur only very rarely. For instance, I don't see the purpose of having an edge with a null source or target.
Stephan van Hulst wrote:I don't like the code that IntelliJ generates, because it uses getClass(). That implies that you can't compare instances of base classes against instances of derived classes. Use instanceof instead and make your equals() method final.
Stephan van Hulst wrote:Not sure what you mean by this, but in general the number of tests you need is not a simple calculation over the number of members of a class. You don't test members. You test assumptions you make about the class. The number of assumptions depend on the class design, not the number of members.
Stephan van Hulst wrote:I'm not sure what you mean by the self test. Isn't it already covered by the reflexivity test?
Campbell Ritchie wrote:You always have to consider the possibility of a field being null when you write equals().
Campbell Ritchie wrote:I am so sorry
Stephan van Hulst wrote:The only test you can perform for hashCode() is that equal objects must have equal hash codes.
Campbell Ritchie wrote:Please explain more
Campbell Ritchie wrote:No. Most people don't write super.equals(ob) in their equals() method, but many people write an == test, which does exactly the same.
Static and non-static generic methods are allowed, as well as generic class constructors.