I'm working on some code that has the following pattern of conditionals inside it. It doesn't look great, but it doesn't look terrible. Please, shed some light on the underlying reason this is not passing my smell test. I'd love to see some alternatives. I'm guessing it's because it's completely ignoring a certain permutation.Note: I'm asking this question with the intent of bettering the code, not code golf.public class RoleManager{    public string Role { get; private set; }    internal void SetRole(bool isManager, bool hasBackendAccess)    {        if (isManager && hasBackendAccess)        {            Role = FullAccess;        }        else if (isManager)        {            Role = Manager;        }        else if (hasBackendAccess)        {            Role = LimitedBackend;        }    }}
Seemingly redundant conditionals...or not?
c#
You have 3 different role values and 1 for not assigning anything, so you'll somehow need 4 discrete values to differentiate. But you could rewrite as:if (isManager)    Role = hasBackendAccess ? FullAccess : Manager;else if (hasBackendAccess)    Role = LimitedBackend;