Hacker News new | ask | show | jobs
by zdw 5233 days ago
If you really want to do a rewrite, first:

- Write comprehensive test cases and run your current product agains them. Have these also benchmark the code if they're performance critical.

- During the rewrite, slavishly adhere to the test cases. If there's an undesireable difference discovered between old/new, write another test case.

- If possible, break up the original product into smaller modular sub-projects you can rewrite independently.

Most problems with rewrites come from starting from scratch - slowly replacing a code base from the inside is a much better way to do it.

3 comments

> If possible, break up the original product into smaller modular sub-projects you can rewrite independently.

This.

Many projects can be done this way. In particular, the process of figuring out the set that can be replaced at any given time can aid in the refactoring.

You should however be careful with the test cases -- if you want to change the internal structure, unit tests can make you use the same interface, and unless your codebase if already well modularized, it will make architectural changes difficult.
Or come up with a plan to gradually replace key areas with new system. I have a real world example of what Joel describes, came up with a plan to do what I am describing it was rejected, a total rewrite done and it was a disaster, the company has never really recovered.