4 ms·
Somewhat related to the "use an enum" approach: Value Objects. Not quite an enum since it's not a design-time constraint, but they can let you "wrap" a scalar
by Terr_ 12y ago
Somewhat related to the "use an enum" approach: Value Objects.
Not quite an enum since it's not a design-time constraint, but they can let you "wrap" a scalar (or series of scalars) into something much more self-documenting, and prevent mismatches, like where someone substitutes length for mass.
For your example it'd be overkill since there are only four states, but if there was some additional related piece of information, like a number for tolerance, you could make an immutable object to group it all together.