Production Surprise

I found this while I was debugging a minor production problem this afternoon.

if (userName.Contains(""))
	userName = GetUserName(userName);
 
if (String.IsNullOrEmpty(userName))
	throw new ArgumentNullException("userName can not be null.  Verify identity.Name is not empty.");

This code was written last month during a refactor of this method, and I can not for the life of me understand what userName.Contains(“”) is there for. I am testing for null or empty strings on the line right below it, and I have never in my life written .Contains(“”) to check for an empty string. There are no code or check-in comments, and it was checked into TFS with my username. I would feel more ashamed if I wasn’t partially convinced that someone stole my username and password, logged in as me, wrote this shitty code, and then checked it in.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Reddit
  • DotNetKicks
  • Technorati
  • TwitThis

Leave a Reply