What will you do in this case to reduce the Cyclomatic Complexty
if (Name.Text == string.Empty)
Name.Background = Brushes.LightSteelBlue;
else if(Age.Text == string.Empty)
Age.Background = Brushes.LightSteelBlue;
else if(...)
...
else
{
// TODO - something else
}
Let suppose I have 30 or more.
It looks like you perform the same logic on each “TextBox” (at least I think they are TextBoxes). I would recommend putting all of them into a collection and performing the following logic:
Note: This does change your code a bit, as I noticed you only check the value of one “TextBox” only if the previous ones did not have empty text. If you want to keep this logic, just put a
break;statement aftertextBox.Background = Brushes.LightSteelBlue;and only the first empty “TextBox” will have its background color set.