I ran across a great example of why to refactor code. We have a system that users fill out some forms and processes are kicked off that route that data to a database and send out emails to different people based on certain user input. Before we rewrote the system in January of 06, to change who got a certain email took at least a 1 hour of coding time and an half an hour of QA. It was way out of wack. We totally rewrote the system in January but because of delays to other parts of the project the system didn’t go live until August of this year. So for 8 months we could have sat on our new code which worked. Instead every 2 months we revisited different code blocks and refactored. At most we spent less then an hour refactoring. This particular code block ended up getting refactored 4 times.
Today, I got a request to route emails to different people, based on new business rules. The end result took 2 minutes of code changes, and 3 minutes to QA. We use Watir to run automated test. Because we use source control I did some auditing. Looking back these are the number of lines of code that would have needed to change for today’s changes.
|Refactor Date||Lines of Code to Change|
Refactoring code rocks!