I usually donโt sell things in advance if I donโt need them.
If my class contains data members, and I plan to store it somewhere, I will usually use equals, hashCode and comparable.
However, I found that most of my classes do not have this problem, so it makes no sense to do this. For example, if your class revolves around functionality on other objects, not data, why bother? If you have one instance or are organized hierarchically (like a GUI widget or window), why bother?
Do not do what you do not need, but always check whether they are needed or not, because Java usually does not warn you.
Also, make sure you use your IDE or something like Apache shared resources to create these functions. Rarely have to manually encode them.
As for toString, I rarely implement it until I find myself in debugging and do not need a better presentation in the Eclipse debugger (for example, instead of the object identifier). I am afraid of implicit conversions and never use toString when generating output.
Uri
source share