I don't have a lot to say, but this is my little bit.

Thursday, February 17, 2011


In ASP.NET, the ServiceProxy object has a GetConfigSetting member method. The method is incorrectly implemented and has a bug when the requested setting is absent. The following trivial code works around the bug, and the comment explains my feelings adequately.

   /// <summary>
/// The original GetConfigSetting method is completely stupid. If you request a setting
/// which does not exist, it throws an exception. Is it exceptional to request a setting
/// which does not exist? No, it is not. The correct behavior is to return a value
/// indicating that the setting does not exist, and obviously that value is 'null'. Thus,
/// to fix the stupid bug in Microsoft's stupid API, I had to write this non-stupid
/// wrapper for the method.
/// </summary>
/// <param name="settingName">
/// <returns></returns>
private string NotCompletelyStupidGetConfigSetting(string settingName)
return GetConfigSetting(settingName);
// translate the stupid exception into a non-stupid correct null value
return null;

No comments:

Post a Comment