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#:
EditorDatabase EditorDB = new EditorDatabase();
if (UserIDTextBox.Text == "0" && LoginRoleDropDownList.SelectedValue == "11")
{
    EditorDB.Save(CodeHiddenField.Value, TextGridView.Rows[rowID].Cells[5].Text,
    System.Convert.ToInt32(TextGridView.Rows[rowID].Cells[10].Text), TextGridView.Rows[rowID].Cells[8].Text,
    0, spr, TextGridView.Rows[rowID].Cells[11].Text).ExecuteNonQuery();
}
else
{
    EditorDB.Save(CodeHiddenField.Value, TextGridView.Rows[rowID].Cells[5].Text,
    System.Convert.ToInt32(TextGridView.Rows[rowID].Cells[10].Text), TextGridView.Rows[rowID].Cells[8].Text,
    System.Convert.ToInt32(UserDropDownList.SelectedValue), spr, TextGridView.Rows[rowID].Cells[11].Text).ExecuteNonQuery();
}

Designed by SirMike © All rights reserved

Valid XHTML 1.0! Valid CSS!