128 reputation
3
bio website
location
age
visits member for 1 year, 10 months
seen Aug 5 at 21:27

Oct
5
awarded  Scholar
Oct
5
awarded  Supporter
Oct
5
accepted Should Equality be commutative within a Class Hierachy?
Oct
5
comment Should Equality be commutative within a Class Hierachy?
I like this. However that is the contract for the method equals(object). What if the derived class has an overload of equals, say equals(T)? Would you say that equals(object) where object happens to be of type T, should behave the same as equals(T) and therefore be bound to the cited contract?
Oct
5
comment Should Equality be commutative within a Class Hierachy?
Where would is as part of a team maintaining an inherited C# code base. The original author did a mix of overriding Equals, implementing providing strongly-typed overloads of Equals (sometimes implementing IEquatable<>, sometimes not actually overriding equals), and always returning base.GetHashCode(). The HashCode issue was really causing problems so now it returns a constant. There is another bug shown to be a result of the inconsistent equality behavior between the strongly-typed overloads and the the inherited Equals(object) which now I get to fix.
Oct
5
awarded  Student
Oct
5
asked Should Equality be commutative within a Class Hierachy?