I've read a lot of Refactoring literature as of late and a common theme I see in examples is the reduction of lots of IF statements. The below is a very simple code block that first checks to see if an email address is supplied and if so, then proceeds to validate the email address. I typically see a lot of this type of code which always looks a bit messy, especially if there are multiple variables.
if (string.IsNullOrEmpty(email)) {
throw new ApplicationException("Email Address Required");
}
else {
if (!ValidationService.EmailAddressIsValid(email)) {
throw new ApplicationException("Invalid Email Address");
}
}
My question is, is this example perfectly acceptable? Does it smell? How might one refactor this snippet?