ObEq library page

ObEq for quick and easy object equality

 

Whenever I catch myself writing a piece of code similar to one I have written in the past I feel very uncomfy. DRY principle is well-known for a reason.

The right cure for duplicate code within a single project is refactoring via class extraction. For the code that’s written again and again in various projects a cure is just slightly different — package extraction is an answer.

So, implementing GetHashCode() and Equals() fifth time in yet another project was quite frustrating. It was even sadder to realize that whenever a new field is added to the target class, the hash code and equality methods must be revisited again but what will remind me or another user of that? Lastly, why should I even bother with these sorts of implementation details when I want to be focused on new feature works or a bug fix?!

It’s time to present ObEq, a tiny .NET open-source library that makes it easy to make equality happen. All you need to do is define an array of fields that are significant for hash code calculation and fieldwise comparison. Interested? Feel free to review it, use it, and fork it!