Great question! Let’s assume for now we are talking about an app that makes money (if not, you should probably shut it down ;)). You can do three things:
- Rewrite from scratch
- Slowly refactor the codebase part-by-part. You should probably use the autonomous bubble pattern here or a similar approach.
- Slowly rewrite the app part-by-part by using the strangler pattern (I will write a post about that one too)
Depending on different factors like the number of lines, code messiness, etc. you should use the second or the third approach. Our preferred way is the last one. It allowed us to introduce good patterns and processes in the new part quickly. We are currently doing a rewrite using this approach, and we release up to several version a day. The deployment takes 3–4 minutes, we have automated tests, the app is containerized, etc.