Talk:Equals vs the Encapsulation Boundary
This is the result of a group discussion between Ben, Alex, Matthew, Michal and Stephen --Matthew Harward 05:08, 30 July 2009 (UTC)
I would agree with Wal that you shouldn't need equals() often in the case where you are simply checking to see if two objects are the same object. However, this still leaves the equivalence case, which I think is much more reasonable. I disagree that the equals() method is likely to only be checking things which are publicly accessible. I think that much of the time equals() will be checking private things. In this case I would ignore the evil of class encapsulation, and simply use it to our advantage. In languages which don't even allow class encapsulation I'm at a loss. --Aidan 09:56, 1 August 2009 (UTC)
Since Java allows incest on your siblings, I'd probably use that for equals() without writing getters for all the private/protected fields. As long as one only reads from those fields, not much damage is done. However, I still think that this (incest) is quite evil. Maybe if a programmer uses it only for that equals() case it might be ok ... I've done most of my projects in C++ and Python and I have to say that I never missed accessing private attributes of other objects (I used C++'s friend ability many years ago but I think it's pretty bad as well). --TobiW