I need to update a class. It has a boolean e.g. IsTypeA.
There are currently two conditions in the system i.e. 1. IsTypeA or 2. not IsTypeA.
This is referenced in a lot of places under the standard conditions if(IsTypeA) do X else do Y. It is also used in integrations and external data, so i am not allowed to change it. I can only add to the class.
We now have a new condition, so IsTypeA needs to have 3 states.
It would seem hacky to have another boolean (say IsTypeB), which trumps the IsTypeA boolean. It would also make the code hard to follow and rubbish if another type, say TypeC, came into play.
What is the best practice for dealing with this scenario please?
I am considering doing the following:
[Obsolete("Please refer to property 'MyType' for new usage", false)]
public bool IsTypeA
{
get { return _isTypeA; }
set
{
_isTypeA = value;
if (value == true)
MyType = EnumMyType.TypeA;
}
}
private EnumMyType _myType;
public EnumMyType MyType
{
get { return _myType; }
set { _myType = value; }
}
(I have previously googled. Found this question, which is similar, but in that instance the dev is updating the whole class. I only need to update one property within the class).