At work recently, we had code looking a little something like this:
When refactoring the code, I thought about the recent blog post about A Less Ugly Switch Statement and thought I might do something similar with IComparer (and IComparable, but I’ll leave that as an excercise for the reader). The envisioned invocation is:
I ended up with this implementation:
Is this better? I’m not really sure. It is functionally equivalent. Is it more readable, or less?