When is it worth rebuilding a component vs patching it?
On this page
Rebuilding a component is worth it when patches have piled up into fragility, when the underlying approach can no longer support what the component now needs to do, or when the cost of continuing to maintain it exceeds the cost of starting over; patching suits small, isolated fixes on a foundation that is still sound. The single test underneath all three conditions is whether the foundation is still capable of carrying the requirements. Stop patching when the base itself has become the problem, and keep patching as long as the base is sound and the fix is local.
The reason the foundation is the right thing to test is that patches and rebuilds fail for opposite reasons. A patch is cheap and safe precisely when the structure beneath it is healthy, because then a fix is a fix: it addresses the specific issue without disturbing the rest. But once the underlying approach is wrong for the current need, every patch becomes a workaround layered on a workaround, and each one makes the next change harder and the whole thing more brittle. At that point patching is not saving you money; it is borrowing against the future at a rising interest rate, because the real defect, the base, is still there, and you are paying to route around it again and again. A rebuild is expensive up front but it pays down that principal, replacing the unsound foundation instead of decorating it. The decision is just a question of which debt you would rather carry.
Take a date-range picker that started life handling a single date. Over two years it accreted patches: a second field bolted on for the end date, special-case logic for when the start is after the end, a flag for disabling weekends added in one place, another for blackout dates added in a different place that does not quite cooperate with the first. Now the team needs presets like “last 30 days” and multi-month display, and every attempt to add them breaks one of the existing special cases, because the component was never structured to hold this much. The foundation, a single-date model with exceptions stapled on, can no longer support what is required, and the symptom is that fixes keep producing new bugs elsewhere. That is the moment to rebuild around a model designed for ranges from the start. Contrast it with the same picker when all that is wrong is a misaligned icon and a color that fails contrast: the structure is fine, the fixes are isolated, and rebuilding would be throwing away a sound base to fix two cosmetic issues. There you patch.
The catch is that “the foundation is unsound” must be a real structural judgment, not a tidiness reflex or a preference for fresh code. Plenty of components look messy inside but are perfectly capable of carrying what is asked of them, and rebuilding those buys nothing but risk, since a rebuild reintroduces every bug the old version had already absorbed over its life. The cost test guards against this from the other direction: even a somewhat sound foundation can be worth replacing if maintaining it genuinely costs more than a rebuild would, but that has to be a measured comparison, not a hunch that new would feel better. And the keep-patching habit guards against the opposite error, where a rebuild keeps getting deferred as too expensive while the patches quietly compound the fragility past the point where a rebuild would have been cheaper.
So when you face the choice, look past the surface symptom to the base and ask one thing: can this foundation still carry what the component is now required to do. If yes, and the fix is local, patch it and move on. If the base can no longer support the need, or each fix keeps spawning new failures, or maintenance has outgrown what a rebuild would cost, rebuild it. Decide by foundation soundness, and stop patching the day the base itself becomes the thing you are fighting.