Refactoring - Good or Bad?

October 10, 2008

If you're anything like me, you go to make a change to some code you wrote a year ago and wince. I want to drive right in and get rid of my horrible clunky old code and replace it with my nice new shiny code. The problem is that although this will give me a warm glow inside, it isn't actually going to make my application work any better. Sure it might be a bit faster, have improved maintainability and comply with my current best practice; but that's just it; it will be my current best practice and it probably seemed maintainable when I wrote it. The chances are that in a years time I'll open up the same script and wince!

I don't really have a point that I'm trying to make. It just seems to me that often it is better to stick with our old code and just tweak it rather than rewrite large sections. Of course, if you are making radical changes then it makes sense, but when time is money then maybe it is not always the right thing to do. Any thoughts?


2 comments

  1. I know we have all heard of the old saying "If it isn't broke don't fix it". I can agree with it to a point. If you have an application running for a client are there are no changes being made, there is no need to go back and Refractor. IF you are however in the middle of a project and find an instance where Refractoring makes sense I do it. The more you can abstract out and re write the better the project will live in the future.

    Just my 2cents

    Comment by Dan Vega – October 10, 2008
  2. Hey Dan, I think my general rule of thumb is going to be that if I'm introducing a new framework, such as Transfer or Lightwire then it makes sense. Otherwise, I should only do it if it solves a specific problem.
    In reality it's going to depend on how tight the schedule is!

    Comment by John Whish – October 13, 2008

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.