Imagine a system for loan applications where loans can be in one of three states: PENDING
, APPROVED
, REJECTED
.
Over time, people create code, UIs, internal reports, etc. that assume there are only 3 states. It's unlikely a single person knows all of the places where this assumption is made.
An idea I had is to create cheap "reminder" unit tests like this that fail whenever a state is added/removed, and let the developer know the potential impact of their change:
assertEquals(["PENDING", "APPROVED", "REJECTED"], LOAN_STATES, "Update finance's XYZ report to handle this new state")
assertEquals(["PENDING", "APPROVED", "REJECTED"], LOAN_STATES, "Microservice XYZ assumes there's only three states, revisit code in file ...")
assertEquals(["PENDING", "APPROVED", "REJECTED"], LOAN_STATES, "Let external API integration partner know about the new state")
How can this be used in a meaningful way to prevent high-impact structural changes from occurring? Are there any related concepts for minimizing or at least detecting the impact of changing business logic?