Ever since reading Clean Code I have been trying to keep my code descriptive and easy to understand. I have a condition where either A or B must be filled in. But not both. And not neither. Currently the if
statement to check for this condition is hard to follow at a glance. How would you write the following to make it clear at a glance what is being checked
if ((!string.IsNullOrEmpty(input.A) && !string.IsNullOrEmpty(input.B))
|| string.IsNullOrEmpty(input.A) && string.IsNullOrEmpty(input.B))
{
throw new ArgumentException("Exactly one A *OR* B is required.");
}