This subject keeps coming back again and again.
Please let agree, once and for all, that
we would all benefit from a decent, non-trivial,
default implementation of
toString ()
equals()
hashCode()
Example :
---------
Yesterday, I had to create 4 persistence linked classes, with 20 fields each.
4 times, I had to create, no-brain required,
- a no-arg constructor
- a 20-field constructor
- 20 setters
- 20 getters
but also, I had to overide and create (very few brain-required)
- a 20 field toString ()
- a 20 field equals ()
- a 20 field hashCode ()
IDEA has a smart default behaviour for only the first 4 tasks,
but I cannot see how / why overriding
toString ()
by (your choice may vary)
public String toString () {
return "[MyClass: " + field1 + ", " + ..... +]"
}
is so different from implementing constructor the way we do now.
The same is valid for
equals ()
hashCode ()
If you want a simple and "standard" recipe,
look in "Effective Java",
p 33 : equals ()
p 38 : hashCode ()
I wouldn't say no to a smart default for
compareTo()
either.
Alain Ravet
This mail has been checked by exiscan.
To be safe, please scan the mail attachements with your local virus scanner !
_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features