I have often been in situations where we decided to reuse existing code. Business people seem to think that reusing existing code is free. After all, this is the promise of paradigms like OO. But in reality, retrofitting code for a new usage often proved nearly as costly, or sometimes even more so than if we had started from scratch. This is not necessarily a bad thing. Having a component with multiple uses makes sure it is well tested, and that all consumers benefit from maintenance and improvements.
This becomes different if the code has no active support developer/team and if we don't want to adopt it either. Reading code is much harder than writing it. This becomes worse if original devs are not involved/available, technology used is outdated or poor design choices were made.
When you rewrite this code, it is up to modern technology standards. It also reflects the latest business insights, and fixes design flaws of the existing version. But most of all, when you rewrite it, you know the system inside out, and will answer questions instead of asking them. This return on investment is often overlooked. We should be less hesitant to dispose code and rewrite it.
There is an article by Erik Dietrich, pointed out by Assen Kolov, on the subject.
Photo by Steve Johnson from Pexels