by Michael S. Kaplan, published on 2010/01/04 07:01 -05:00, original URI: http://blogs.msdn.com/b/michkap/archive/2010/01/04/9943362.aspx
Sometimes even when two problems are different, there are very strong similarities -- and the answer is still the same.
Like the other day, when Jacques asked:
Is there a standard way to determine if a given locale orders the firstname/surname as "First Last" or "Last, First"? I have looked through the Globalization namespace but haven't found anything useful. Is there a built-in way to do this or do I need to implement my own?
Thanks.
Now this may remind some regular readers of What's in a name? from way back when, though it was really more talking about parsing names in general (in order to find the last name), rather than the display order of names in general.
However, the two problems are obviously related, and share a common heritage of the overall complexity of names - a complexity that doesn't ever seem to get any easier.
So the quick answer for Jacques is that there is no such beast in the Globalization namespace.
And the long answer is that not only is there no such thing but one should not try to write it oneself, for the very same reason that there is no built-in solution in the .NET Framework. Because any such solution will be incomplete across the huge variety of issues in names!
Now in a way, the two problems are converse issues (one is given a display name how to parse out the constituent parts, while the other is given the constituent parts how to construct the full form of the name for display) so perhaps one could think of the problems as being merely on the other end of the telescope (pardon the oblique musical reference!).
This is the kind of problem that apps like Outlook Express/Windows Mail/Windows Live Mail have had lame solutions for all along, a lameness that is pretty much mitigated by the easy way users have to notice the problems when they occur and override the program's guesses
But one could take a step back and ask WHY the question is being answered in each case - what scenario leads one to have just one kind of information while needing the other - in order to come to the ideal solution for the problem.
It may involve creating a localizable solution so that a localizer (someone meant to be the most knowledgeable person about users expectations in a given culture) can give the user sensible defaults that the user can then override when the code falls short.
Or it may involve just making sure to ask for the information, all of the information, explicitly. And not try to be too clever in the code.
If you look in not just What's in a name? but in the comments to it, there are countless examples that should tend to dissuade even the most eager developer hoping to try to add this particular feature as a pure code solution meant to solve the problem, since you can't. :-)
John Cowan on 4 Jan 2010 6:45 PM:
My screed "Against Structured Names And Telephone Numbers" can be found at http://docs.google.com/Doc?docid=0Ab8UUpsyGZ0wZGM0NnFyZGZfMTN6M3F0N2dq&hl=en .
Michael S. Kaplan on 5 Jan 2010 11:04 AM:
Yep, that lays it out nicely....