Rewriting a code base (including CM code)?

This is the age old debate. When do I start over? There are a lot of considerations here. The code that got you this far may be showing a lot of wear and tear. Here is a summary of thoughts others have already put out here:

Pitfalls

Methodology

If flawed methodology, more than tools/languages, is the source of your problems and you don’t address that, you will rebuild your mess in a different language and not solve much.

Developers like to write new code more than read/deal with existing code

It’s much more fun to create your own thing than deal with someone else’s creation. I think it’s wise to acknowledge this may be a not so good motivation in rewriting a new system. As others have written, it might make sense to refactor and improve test coverage on your existing code base rather than rewrite from scratch.

The existing app probably has more scope than you realize

If you think you have the exact scope and a plan with precise estimates to rebuild it, you might be surprised how much functionality is not reflected in that plan.

You will never rebuild a like for like

Times change. You probably will want to do something different than you did before. That means it’s no longer a code porting exercise.

New features and the business

The end result of a rewrite is a net zero to customers and the business from a functionality standpoint. That can (and should) be a tough pill to swallow.

Does this apply to CM too?

YES! Devops, infrastructure as code, and configuration management (CM) can suffer similar pitfalls. It’s important to keep in mind what I mentioned above about methodology. If you have a flawed process with Salt and decide Ansible is the solution to the problems, you might waste your time.

How might I do this?

  1. Don’t rewrite, just refactor. Especially if the business and users are somewhat happy with the application. A key part of refactoring should of course be about tests and making the code easier to reason about.

  2. Gradually replace with the strangler fig pattern

Other resources

I like Justin Fuller’s post at https://www.justindfuller.com/2020/01/why-do-we-fall-into-the-rewrite-trap/

Martin Fowler coined the term strangler fig application, see https://martinfowler.com/bliki/StranglerFigApplication.html

The site he references, https://paulhammant.com/2013/07/14/legacy-application-strangulation-case-studies/, also has some good material

Brady Wied