The stars have aligned, and you’ve gotten the go-ahead to significantly overhaul some software. Figuring out if you should blow away the existing code and start from scratch, or if you should just rewrite parts of it instead, can sometimes be a challenging and difficult decision. As it turns out, many of the factors to take into consideration closely parallel those of construction on an existing home, where the choice is to either bulldoze the house and rebuild it, or to only renovate certain rooms.
If a house is structurally sound, renovating it should be far less expensive than tearing it down and rebuilding it. The same is true for software development, where if the codebase is well-architected and not a pile of spaghetti code, mending the code should cost far less than rewriting it from scratch. In fact, experience has shown that software rewrites always take far more time and money than anticipated.
The difference in long-term cost is fairly negligible between demolishing and rebuilding a house vs renovating it. With software development, you have to look at how much time is spent fighting fires, how up-to-date and well-supported is the technology used, etc. If the codebase is sufficiently poor in quality and/or constantly limited by the technology used, then the long-term costs of rebuilding it can start to approach and even surpass that of mending it.
A house that has been demolished and reconstructed should theoretically be a longer-lasting solution than renovating an older house, all other things being equal. This is because it can take advantage of advances in building materials, processes, etc. Similarly, a new build of software should be able to leverage newer frameworks and technology for more efficiency and increased capabilities.
Tearing down a house and rebuilding it can take some time, but in certain cases renovations can take just as long due to other factors, such as rewiring electric or plumbing, changing the layout of the house, etc. Depending on the scope of changes and the state of a codebase, renovating it can also take quite a bit of time, but as a general rule it would most likely come in well under a complete rewrite.
Every project is different, but deciding on how to approach it usually comes down to cost and timeframe constraints, in which case renovations have the edge. As an added bonus, much like how a house can sometimes be livable during renovation, your code could continue to function and be useful while changes are being made.