| My biggest issue with Comparator has always been that it doesn't feel as object oriented as implementing an interface. I like having the method for comparing the objects as part of the object. In the end, I know it's just my personal preference.
Yeah, even Sun will recommend that you don't use reflection unless you absolutely have to. The sort on any string question though makes me want to write it just to see how well it works.
The use of static variables (IMO) have their place. There are certainly limitations and gotchas that you rightly pointed out. In this case, I'm only talking about holding the name of the field that will be sorted on, not the actual values, but under the right circumstances, I suppose that could be an issue. You could just as easily hold the "sort field name" outside the class, it just appeals to my sense of order when using Comparable that the value be accessible within the class/object.
Later. |