Some objects are more equal than others - a look at the many meanings of equality, value and identity

By Roger Orr & Steve Love

Equality is a fundamental concept in programming but is surprisingly hard to get right. Its importance is shown by the way that in most languages it is a symbol (not even a keyword) - although the variation between "=" and "==" continues to catch people out!

In languages that allow you to define your own types it is important to get equality right -- but what does "right" mean in practice?

We will look at the slippery concepts of equality, value and identity and discuss what pitfalls there are in using them. This is important in places as varied as database persistence and reliable unit tests - and also becomes a 'key' issue when you are working with associative collections.

Equality can be hard enough to get right for a single class; but additional issues arise with hash codes for objects and when you start using class hierarchies. We will work through an example of trying to get this right based on experience with real-world problems.