If you want to compare two in-memory objects, you can use method generators, there are several related articles and discussions on that:
- Exploring Code Generation with Caché Method Generators
- Generic way to test if all the propertiers of an object are null
- Cheap object hashing?
Simple comparator on GiitHib - note that it's a runtime comparator, therefore slow. Better solution would be method generators.
If you're comparing objects of different classes you need to find their common ancestor class and compare using that.
If you're comparing stored objects you can calculate hashes and compare that.
All in all it's a very complex topic and you need to determine what requirements do you have:
- Streams?
- Lists? Arrays? Position change?
- Loops/relationships strategy
- How many levels to compare?
- Different classes? Do they have common superclass?
- Do you need to compare dynamic objects/objects from unrelated classes?
And design your comparator based on that.
Here's a simple hasher on GitHub.
- Log in to post comments

