POCO comparison discussion

How would you compare two POCO‘s, which are instances of the same type?

Assuming you only want to compare the public properties, which can be simple or complex types.

While discussing this shortly with a good friend, we came up with three naive options.
You can check them out on GitHub, but i’ll summarize them here:

  1. Manually compare properties
    1. I don’t think this is very future proof or¬†maintenance friendly, because adding a property but forgetting to update the comparison¬†algorithm¬† is very real (as a professional mender I have a sixth sense for this kind of things)
  2. Compare serialized JSON string
    1. We didn’t come up with this, but kind of encountered this in production code. I think this solves the future proofing, but i’m wary of the performance implications.
  3. Compare via reflection
    1. This sounds obvious, we did wonder how far this rabbit hole goes when you have properties with a complex type, we foresee some comparison challenges.

Send a pull request if you got a crazy idea.

Theme music for this blog post

POCO comparison discussion