The other day on Twitter there was a stream whether it is better to completely scrap an applications code base and start over, or refactor from within. Now I do want to state right now:
The information here is based on my experiences and is simply my opinion. I know this is almost on par with the average biblical debate so lets just agree to disagree now.
Anyway, now that I have put on the standard disclaimer lets continue on with the post. As I stated there was a debate on which was better, rewrite or refactor…..
Once upon a time I thought that without a doubt that rewriting that crap filled, unmanageable and unextendable code was the ONLY way to succeed. However, during my career I have come to the conclusion that rewriting was actually the wrong decision and refactor from within is the right one. Here are some of my thoughts as to why
- You get to scrap that old code that smells.
- You get to build a better, more maintainable architecture going forward.
- You get to use the latest technologies and this is always the best thing.
- We know the business better now, this will allow us to create a better, more flexible application
- Is the business going to actually stop innovating or changing long enough to let you completly rewrite the application? NO
- If they are not going to stop moving forward this means there is going to be a maintance team doing this type of work. This means you are coding against a moving set of requirements that will change daily… FAIL
- What makes you think that you can write it better the second time around? If you wrote unmaintable crap the first time why do you think you are better now (ok, assuming you did write it the first time).
- More than likely you are simply going to pile on the latest tech because you can. Because you are an ego freak and the only way to write good code is to use new tech
Refactor from Within
- You have the ability to continue delivering new versions of the application with new features.
- You actually increase your knowledge of what ‘crappy’ code looks like and how to fix it.
- You can learn how to refactor your legacy code with minimal risk and learn how to do it a way that allows you to deliver new code
- This is NOT easy
- This is NOT slow
- There is always the thought that you will never actually be complete and that the refactor effort will be dropped at some point in the future. If this is true, rest assured that your application will be better off anyway.
Ok, there you have it, my list of pros/cons for each (this is not an all encompassing list, just some of my random thoughts). In my opinion the refactor is a better, safer choice. But this is not as sexy and takes a ton more effort and patience. However, I believe in the long run you will be better off.
Till next time,
07-13-2009 2:39 PM