Something .NET does less intuitively than they ought

by Michael S. Kaplan, published on 2007/06/01 02:59 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2007/05/31/3019659.aspx


If you are someone who reads the BCL Team blog, you may have seen Josh Free's String.Compare() != String.Equals() that he just posted.

Of course this is old hat if you are a regular reader here and remember seeing Invariant vs. Ordinal, the third or Something .NET does more intuitively than Windows, both posted last year.

Even just today, I was asked by someone to provide some comments for this MSDN topic to clarify something in the comments for the String.Compare Method (String, String, Boolean) overload.

The specific question related to which StringComparison enumeration member corresponded to that third ignoreCase parameter. Which is not clear to everyone. But then that whole overload wasn't necessary (more on this in the future).

And I just realized that I am sick of all of the extra overloads off of System.String, the StringComparison enumeration, the StringComparer class, and all of the rest of the confusing methods that are there, all of which should have and could have been replaced with a simple usage of CompareInfo for linguistic comparisons.

The whole reason methods kept getting added is that although they found the one method with an enumeration confusing, they found the one method with no options to be too limiting. So they started adding overloads and methods and named them such that no one could ever know which one to use without reading a fifteen page document that no one understands, not even the really smart developers.

"But Michael," they tell me, "the System.Globalization namespace is not referenced by default." This is an argument I refuse to by since every time there is an interface that is important feature, it does get added by default, like Generics did in VS 2005. So System.Globalization is clearly not important enough to include, but it is important enough to wrap dozens of different ways that no one understands.

Grrrr.

Ok, I am over it now....

That is part of letting go when you work in new areas like I do now -- you have to try to not jump into the old area all the time if you think people might be doing something that you don't care for....

Though on the plus side, I do get to help out some teams work through these issues (I'll blog about this soon), and I suppose I still get to complain here.... :-)

 

This post brought to you by Щ (U+0429, a.k.a. CYRILLIC CAPITAL LETTER SHCHA)


no comments

referenced by

2008/05/21 String.StartsWith || String.EndsWith != String.Equals, either

2007/08/31 Elegant? Beyond compare...

go to newer or older post, or back to index or month or day