I was peeking at Code Reviews and I saw this code.
retrievalUser.Surname = Formatters.ToTitleCase(usersName.Item as string); retrievalUser.GivenName = Formatters.ToTitleCase(usersName.Item as string);
Notice how the code for both Surname and GivenName is exactly the same.
How can that possibly work? If “usersName.Item” is the full name like Alan Taylor, then surely if the UI shows GivenName and Surname, then it will be displayed as “Alan Taylor Alan Taylor” which is obviously not their name.
If this is some temporary code, then why haven’t they added a code comment next to the code to highlight that this needs replacing? Something like “Currently, the API only returns the full name so we cannot determine the users Surname and GivenName until version 2.1”.
Also, is it even correct to Title Case someone’s name? If you have a name like McDonald, wouldn’t this become Mcdonald? There’s probably loads of other examples too. I think the Dutch “van” is lowercase like “Robin van Persie”.
So there’s not much right with these 2 lines of code.