In a very large and old codebase, suppose we’re using a database column status
with enum values as NEW
, IN_PROGRESS
, COMPLETED
, REJECTED
.
Now this status
is used in multiple conditions in code like
if (status == `NEW` || status == `IN_PROGRESS`) {
// do something
}
or might be in some SQL statement like
WHERE status NOT IN ("REJECTED")
Now if we want to add a new enum value to status
eg. “CANCELLED”, then we’d have to handle all the places where status
was used in the code.
Considering that the codebase can be somewhat distributed, large and quite old, it would prove to be very difficult for this sort of change. How can we improve this such that it would be easier to maintain these sort of changes?