We’re currently facing decisions to rebuild or refactor some of our code. So, I’ve taken to the web to uncover what others say about this question and have come up some results (frequently mixed I might add).
After a few conversations with peers and today’s reading on the subject, here are some of the key points I’ve taken away on the question of whether to rebuild code. There’s a solid discussion on Stack Overflow regarding this question as well.
Think about refactoring first because:
- The previous developer has seen a lot of bugs from experiences you don’t have. Old code can be ugly, but it was done for a reason.
- It’s a common and natural tendency for developers to want to rebuild an application. Most often, it’s a better usage of time and resources to refactor.
- Code has become so messed that you can no longer maintain it.
- Code is next to impossible to stabilize.
- Any changes will set negative ripple effects through the app making them take a lot longer than they should.
- Obviously, when you can adequately perceive the costs and time-value of refactoring to exceed that of a rebuild.
- Try to break off parts you are going to rebuild and do it one by one.
- Rewrite code progressively, one step at a time validating you didn’t break anything.
- Redesign and rewrite an application stealing snippets from the original code
I’m new to the concept of refactoring vs. rebuilding but it’s a topic of high importance. What did I miss?