<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx</link><description>We are exploring the possiblility of changing the design of IComparer&amp;lt;T&amp;gt; and IComparable&amp;lt;T&amp;gt; interfaces that will ship with Whidbey. This post describes some more detail on the issues we are trying to address with the design change and we are</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#248903</link><pubDate>Thu, 28 Oct 2004 08:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248903</guid><dc:creator>Jesse Ezell</dc:creator><description>Yes. This is a very good idea.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#248907</link><pubDate>Thu, 28 Oct 2004 08:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:248907</guid><dc:creator>Jesse Ezell</dc:creator><description>PS:&lt;br&gt;&amp;quot;More interfaces to understand. Makes the Framework less approachable.&amp;quot; isn't a valid concern. You are not really adding any surface area to the framework. If anything, this makes the framework more approachable, because you only have to implement the functionality you need, rather than writing a bunch of hash or compare code that you are never going to use. Someone who is just doing a simple compare operation might not have any idea how to implement a good hashing strat, which sucks if they really don't need that functionality anyway and waste a bunch of time just to make sure their interface returns valid data if someone else should happen to come along and use it with a hash table. In fact, leaving this the way it is currently would probably result in a bunch of broken comparer classes, because a lot of people wouldn't bother to implement the stuff they aren't using.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249153</link><pubDate>Thu, 28 Oct 2004 21:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249153</guid><dc:creator>damien morton</dc:creator><description>The splitting seems to be a good approach, keeping ordering and equality/hashing semantics separate.&lt;br&gt;&lt;br&gt;Maybe make the naming more explicit though&lt;br&gt;&lt;br&gt;interface IEqualityProvider&amp;lt;T&amp;gt;&lt;br&gt;{&lt;br&gt;  bool Equals(T x, T y);&lt;br&gt;  int GetHashCode(T x);&lt;br&gt;}&lt;br&gt;&lt;br&gt;interface IOrderingProvider&amp;lt;T&amp;gt;&lt;br&gt;{&lt;br&gt;  int Compare(T x, T y);&lt;br&gt;}&lt;br&gt;&lt;br&gt;or even IHashComparer&amp;lt;T&amp;gt; and ISortComparer&amp;lt;T&amp;gt;</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249169</link><pubDate>Thu, 28 Oct 2004 21:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249169</guid><dc:creator>Matthew W. Jackson</dc:creator><description>Yes this is good.  Something that is equatable isn't always comparable.  A complex number needs Equals(Complex), but there's little need for CompareTo(Complex).&lt;br&gt;&lt;br&gt;What's worse, having equality/comparison on the same interface implied that they did the same thing (Equals==true when Compare==0), and you guys went so far as to say they had inter-related contracts that enforced the same thing.&lt;br&gt;&lt;br&gt;But this contract was broken right out of the gate with String, so I think equality needs to be separated from comparison.&lt;br&gt;&lt;br&gt;Also, there are MANY times when I want a class's sorting (comparison) to have nothing to do with equality.  I may have a Customer object, and I want this to use reference equality (every instance is only equal to itself), but it'd be nice if a Customer would sort by its LastName property by default.  Under the current interfaces and &amp;quot;inter-related contract,&amp;quot; this is difficult to do and still feel good about myself at the end of the day.  If I can implement IComparable&amp;lt;Customer&amp;gt; but not IEquatable&amp;lt;Customer&amp;gt;, falling back on reference quality and hashing (boxing would not be an issue in this case), then I feel good about my design decisions.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249171</link><pubDate>Thu, 28 Oct 2004 21:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249171</guid><dc:creator>Jouko Kynsijärvi</dc:creator><description>Yes. Do the split!&lt;br&gt;&lt;br&gt;(But since i opened the MSDN feedback thread mentioned, i'll guess you already know what i feel about this topic...)</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249187</link><pubDate>Thu, 28 Oct 2004 21:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249187</guid><dc:creator>damien morton</dc:creator><description>BTW - your stylesheet works badly in Firefox. When I mouse over any text on the page, the text dissapears. </description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249206</link><pubDate>Thu, 28 Oct 2004 22:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249206</guid><dc:creator>Matthew W. Jackson</dc:creator><description>Sorry for taking this off topic, as I don't want to detract from this important discussion, but...&lt;br&gt;&lt;br&gt;The &amp;quot;mouse hover&amp;quot; bug with this website doesn't appear to be a CSS bug.  According to the DOM Inspector (which IE doesn't have *grin*),   a whole section of the website is inside an &amp;quot;a&amp;quot; tag.&lt;br&gt;&lt;br&gt;Maybe IE interprets junk-html differently than Gecko.  That's the problem with tag-soup--there is no 'standard' for interpreting bad markup.  &lt;br&gt;&lt;br&gt;But please consider doing something about your website.  Sorry again for the off-topic comment.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249213</link><pubDate>Thu, 28 Oct 2004 22:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249213</guid><dc:creator>Matthew W. Jackson</dc:creator><description>Sorry again...  I found the exact culprit.  Your anchor for the comments is '&amp;lt;a name =&amp;quot; feedback&amp;quot; /&amp;gt;' which should have a full '&amp;lt;/a&amp;gt;' rather than shorthand since you're serving HTML and not XHTML.  This is causing all of the comments to be inside an &amp;quot;a&amp;quot;, and since you are styling a:hover instead of a:link:hover, everything goes screwball in Gecko.</description></item><item><title>re: IComparer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249222</link><pubDate>Thu, 28 Oct 2004 22:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249222</guid><dc:creator>Mads Houmann</dc:creator><description>A very good idea - and there really is no *explosion* of interfaces.&lt;br&gt;&lt;br&gt;Just two interfaces to consider when implementing a normal class, and three interfaces when implementing provider-type classes for ordering or hash code generation. Also, the last three can safely be ignored in many cases.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249260</link><pubDate>Fri, 29 Oct 2004 00:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249260</guid><dc:creator>Curt Hagenlocher</dc:creator><description>I like the name IOrderingProvider as well.  It's far less ambiguous than IComparable.  I suppose that tradition demands that crazy &amp;quot;int&amp;quot; return type instead of some kind of (LessThan, EqualTo, GreaterThan) enumeration.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249293</link><pubDate>Fri, 29 Oct 2004 01:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249293</guid><dc:creator>Joe White</dc:creator><description>I'll definitely vote in favor of this change. I'm still on 1.1, and I'm very much looking forward to an interface that lets a third party say &amp;quot;yes, those are equal, no they're not, here's the hash code, and don't ask me about ordering&amp;quot;. I was disappointed to find out that was on IComparable, because most of my comparers would just have to throw NotSupportedException from the Compare method, which would do bad things to code usability.&lt;br&gt;&lt;br&gt;I agree that the number of interfaces is -not- a downside. If you have one interface, but a third of the implementers throw NotSupportedException on half the methods, and another third throw on the other half of the methods, and only a few classes actually implement the whole interface, that's a hint that you need to partition the interface. Partitioning this guy will make things more usable, by making the code much more intention-revealing.&lt;br&gt;&lt;br&gt;Yes, it would take more work to convert from one to the other (if that ever comes up), but (a) it won't likely happen too often, as they're used for different things, and if it does come up it'll probably be very early in the development cycle; and (b) it's still much better than using a class just because it implements IComparer, and not finding out until runtime that it can't do what you need.&lt;br&gt;&lt;br&gt;On IEquateable: Please take out the extra &amp;quot;e&amp;quot;. Make it &amp;quot;IEquatable&amp;quot;.&lt;br&gt;&lt;br&gt;I'll also say that I prefer IOrderingProvider instead of IComparable, but it's not a strong preference - if you left it as IComparable, I wouldn't be too sad.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249306</link><pubDate>Fri, 29 Oct 2004 01:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249306</guid><dc:creator>Scott Hanselman</dc:creator><description>I totally like this change.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249329</link><pubDate>Fri, 29 Oct 2004 03:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249329</guid><dc:creator>Robert Bullen</dc:creator><description>I'm in favor of the proposed new design.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249523</link><pubDate>Fri, 29 Oct 2004 15:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249523</guid><dc:creator>Raymond Lewallen</dc:creator><description>I like the new proposed design.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249524</link><pubDate>Fri, 29 Oct 2004 15:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249524</guid><dc:creator>Cal Miller</dc:creator><description>Go for it!  It's better to fix something like this now rather than after a lot of code is written that could have benefited from the change.  Thanks for asking!</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249563</link><pubDate>Fri, 29 Oct 2004 16:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249563</guid><dc:creator>Samuel Tesla</dc:creator><description>I'll add my Me Too to the stack.&lt;br&gt;&lt;br&gt;I also agree with Joe that you should take the extra e out of IEquateable so that it is just IEquatable, the extra e just looks wrong.&lt;br&gt;&lt;br&gt;I also agree that if you're going to have IEqualityProvider, the name for IComparer should be consistent.  IOrderingProvider is consistent, and furthermore, is more intention revealing.  If you think about it, &amp;quot;comparing&amp;quot; could be either looking at equality or ordering, which is where the original confusion came from.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249576</link><pubDate>Fri, 29 Oct 2004 17:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249576</guid><dc:creator>Fullmetal</dc:creator><description>&lt;br&gt;YES, I agree to this proposal, there is no significant *explosion* it's only a logical distinction, it's clearer and therefore less prone to bugs&amp;amp;frustration.&lt;br&gt;&lt;br&gt;---&lt;br&gt;&lt;br&gt;Like Cal Miller, I thank you for asking: this gives me the idea of some collaboration, and collaboration make the users love the final product! It's good commercial practice.&lt;br&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>re: IComparer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249606</link><pubDate>Fri, 29 Oct 2004 18:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249606</guid><dc:creator>Peter Rust</dc:creator><description>YES, please refactor the interfaces.  Peter Golde's reasons are compelling.  I would argue that NotSupportedExceptions should only be required for exceptional circumstances (implementing an ordered collection or hash table is not exceptional).   This is awkward not only for those who build the collections, also for those who consume them and try to use a method that exists but is &amp;quot;Not Supported&amp;quot;.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#249609</link><pubDate>Fri, 29 Oct 2004 18:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:249609</guid><dc:creator>damien morton</dc:creator><description>Just a quick note to say that Im not sure that there is necessarily an implicit contract between Equals and CompareTo, while there is definately an implicit contract between Equals and GetHashCode.&lt;br&gt;&lt;br&gt;I cant think of any algorithm that will mix the use of Equals and CompareTo - although I can imagine that CompareTo might use Object.ReferenceEquals as a quick test for returning 0.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#250125</link><pubDate>Sun, 31 Oct 2004 06:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:250125</guid><dc:creator>Shital Shah</dc:creator><description>1. Its absolutely logical to keep equality functionality seperate, but then IComparable should and must inherit from IEquatable.&lt;br&gt;&lt;br&gt;2. The IEqualityProvider is plainly an ugly name and also not consistant with its partner IEquatable. I guess there should be a design pattern to avoid suffixes like &amp;quot;Provider&amp;quot; in to names. Even in 1.0, IComaprer was an unfortunate name which drove most users to MSDN and lookup what the hack it meant. My suggestion for names of 4 of these interfaces:&lt;br&gt;&lt;br&gt;IComparable&lt;br&gt;IComparablePair&lt;br&gt;IEquatable&lt;br&gt;IEquatablePair&lt;br&gt;&lt;br&gt;To maintain consistancy,&lt;br&gt;IComparablePair:IEquatablePair&lt;br&gt;IComparable:IEquatable.&lt;br&gt;&lt;br&gt;3. Despite the reasons you have specified, it just doesn't make sense to include GetHashCode in your IEqualityProvider. Its not only incosistant to have this single argument method in this interface but I can imagine several scenarios where I don't want to worry about hash codes when implementing IEquatable or its pair version. It will be really confusing to several novice users what this &amp;quot;hash&amp;quot; thing even means let alone impementing it correctly when all they want to do is just expose euality interface.&lt;br&gt;&lt;br&gt;The current design as it, in my view is ugly (a bad hybrid thats usually born when lot of heads are talking and you have to arrive at some conclusion to satiesfy them all) and incosistance but still a stp forward in right direction.</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#250560</link><pubDate>Mon, 01 Nov 2004 18:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:250560</guid><dc:creator>damien morton</dc:creator><description>Shital,&lt;br&gt;&lt;br&gt;Im not sure that IComparablePair is any more consistent than IEquatable or IEqualityProvider. Clearly, there is room for improvement, however.&lt;br&gt;&lt;br&gt;I dont agree that IEqualityProvider can omit GetHashCode, but then I cant imagine that a novice would ever use the interface. I wonder how many novices use IHashCodeProvider or even IComparer, rather than simply implementing one or more of Equals, CompareTo and GetHashCode.&lt;br&gt;&lt;br&gt;IComparer, IHashCodeProvider and any of the proposed interfaces are advanced concepts that enable the notion of equality and ordering to change for identical objects, depending on what container they are put into. That is an advanced concept.&lt;br&gt;&lt;br&gt;There are several kinds of containers - hash-based containers (Hashtable), sort-based containers (Tree, SortedList), and possibly also pure-equality based containers (such as ArrayList or LinkedList). I would argue that a non-hash, non-sort based container is inefficient and unlikely to be used by the kinds of advanced users who might leverage the power of IComparer and IHashCodeProvider, and therefore can be omitted.&lt;br&gt;&lt;br&gt;So, given that we need classes that support the notion of identity in hash-based collections and sort-based collections, whats needed?&lt;br&gt;&lt;br&gt;IHashComparer, which has an Equals and GetHashCode&lt;br&gt;ISortComparer, which has Compare&lt;br&gt;&lt;br&gt;We could also have IComparer : IHashComparer, ISortComparer, and there the contract between Equals and Compare would have to be respected.&lt;br&gt;</description></item><item><title>re: IComaprer&lt;T&gt; &amp; IComparable&lt;T&gt; Refactoring Proposal</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#268588</link><pubDate>Tue, 23 Nov 2004 20:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:268588</guid><dc:creator>J. Ambrose Little</dc:creator><description>I think I'd prefer the way it is now.</description></item><item><title>
			notgartner.com: Mitch Denny's Blog</title><link>http://blogs.msdn.com/kcwalina/archive/2004/10/27/248847.aspx#667425</link><pubDate>Sun, 16 Jul 2006 18:02:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:667425</guid><dc:creator>
			notgartner.com: Mitch Denny's Blog</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://notgartner.com/posts/2969.aspx"&gt;http://notgartner.com/posts/2969.aspx&lt;/a&gt;</description></item></channel></rss>