Saturday, December 11, 2010

When In Doubt, Do Nothing

If you are unsure about what you are doing it is better to do nothing then to do something wrong. Express this in your code in order to communicate your doubt clearly to your colleagues.


Like in this example:

void OnItemClick(object sender, EventArgs e)
{
  string selected;
  try
  {
    selected = Parse(e.Item.Value);
  }
  catch (Exception ex)
  {
    Log("Clicked Item not found", ex);
    throw;
   }

  switch (selected)
  {
    default:
    break; 
  }
}

No comments:

Post a Comment