On Refactoring and Rewriting

January 24, 2020

Speaking from experience. Trying to “rewrite” a significant piece of the software while still looking back at the old implementation and/or copying pieces of the code from there is the worst decision one can do. For example, backend is in completely miserable state precisely because of that decision of mine.

There’s two points to note.

If you want to rewrite code from the completely blank state, it will take tons of time, especially if you want to cover it with automatic tests alongside (as you should). You save time either by implementing less features or by copying code. Both are wrong.

If you don’t want to lose the corner cases handling accumulated in the existing codebase over time, you basically have no choice other than do it the right way: cover the legacy with autotests then safely refactor under that.

Hacks are not transferrable, as they are tightly coupled to the current implementation, by definition.

Previous: On Performance Next: It's just a Game