Code masters ;)

October 26th, 2007

Every coder sometimes encounters a situation when a bug must be fixed. At the begining it looks for a very easy task... but the code reveals that it might be quite tricky ;) Here is one of most common antipattern - hardcoding mixed with magic numbers. Please fasten your seatbelts :D

C#:
  1. EditorDatabase EditorDB = new EditorDatabase();
  2. if (UserIDTextBox.Text == "0" && LoginRoleDropDownList.SelectedValue == "11")
  3. {
  4.     EditorDB.Save(CodeHiddenField.Value, TextGridView.Rows[rowID].Cells[5].Text,
  5.     System.Convert.ToInt32(TextGridView.Rows[rowID].Cells[10].Text), TextGridView.Rows[rowID].Cells[8].Text,
  6.     0, spr, TextGridView.Rows[rowID].Cells[11].Text).ExecuteNonQuery();
  7. }
  8. else
  9. {
  10.     EditorDB.Save(CodeHiddenField.Value, TextGridView.Rows[rowID].Cells[5].Text,
  11.     System.Convert.ToInt32(TextGridView.Rows[rowID].Cells[10].Text), TextGridView.Rows[rowID].Cells[8].Text,
  12.     System.Convert.ToInt32(UserDropDownList.SelectedValue), spr, TextGridView.Rows[rowID].Cells[11].Text).ExecuteNonQuery();
  13. }

Designed by SirMike © All rights reserved

Valid XHTML 1.0! Valid CSS!

Powered by Rootnode