Model answer
Clarify & scope
I treat refactor versus ship as a risk-and-value decision, not a preference for clean code or speed. First I clarify what the deadline protects, what user outcome the change delivers, and whether the existing code creates a correctness, reliability, or delivery risk. In a financial app, a defect in order placement or displayed balances has a much higher cost than a minor visual inconsistency.
User segments & pain points
I identify who bears the cost of the current code. Users may experience crashes, incorrect states, slow screens, or confusing errors; engineers may be slowed by fragile code, making every future feature riskier. I also ask whether this is a high-change area, such as an order flow, or stable code that is unlikely to be touched again.
Goals & success metrics
The goal is to deliver the user value safely while preserving the ability to make future changes. I look at release impact, defect and rollback risk, cycle time, test coverage of critical behavior, and the expected cost of carrying the debt. I set guardrails around correctness, crash-free sessions, and the committed delivery date.
Solutions
I usually consider three choices: ship the smallest safe change; do a targeted refactor around the risky boundary; or defer the feature for a broader refactor. Recommendation: Prefer the smallest safe change plus a focused refactor when the current structure makes the feature unsafe or repeatedly expensive. I avoid broad rewrites unless evidence shows that incremental changes cannot address the risk.
Prioritization & trade-offs
I compare the cost of refactoring now with the likely cost of bugs and slower follow-on work. I refactor before shipping when the code prevents us from proving critical behavior, creates material production risk, or makes the requested change disproportionately expensive. I ship first when the change is low-risk, reversible, and time-sensitive, while documenting debt and creating a specific follow-up owner and milestone. I make that trade-off visible to product, design, and backend partners rather than silently borrowing quality.
MVP, measurement & rollout
I keep the scope bounded: tests around the risky behavior, a small seam or component extraction, and no unrelated cleanup. I use code review, automated tests, and a staged or feature-flagged rollout where available. After release, I check the agreed guardrails and the follow-up work’s actual cost. If the debt is not creating measurable risk or friction, I do not refactor merely for aesthetics; if it is, I prioritize it with evidence.