Re: Factoring

As most of you know, while I am not doing research, I work on Prospectlinker, the best place on the web to have professional conversations with smart people outside of your network. Prospectlinker has gone through many different iterations, some on paper and some in code, but we are currently working on a big rewrite.

I often wonder if I am the kind of person who just likes refactoring code, or if its really necessary. There is a risk when you refactor since you might be adding additional complexity that isn’t necessary, you might be using the refactoring as a highly productive means of procrastinating (my fav). You really do need to think about certain things before doing a re-write. I won’t pretend by any means to have the answers or even the questions that you should ask since I don’t think there is too much logic that can make the right decision. I think you need to be able to have a look at all the evidence, go for a walk, or a run, or watch some tv, read a book, anything to distract you from the project and then let your brain do a big integration and see if the decision is a good one. If you try this I think you will find your answer.

I am speaking from experience here since this isn’t the first time that we have considered a re-write. When Prospectlinker made the change from nkdGuru, I fought very hard to re-write the code, I fought myself, and my team. In the end, after some anti-thinking (feeling more than thinking) I realized that we had enough of a good base that could be adopted to convert nkdGuru to Prospectlinker. At the time, it was the best move and I would make it again given the same circumstances, however, I now know that it was the wrong decision.

There is more to re-writing code then simply writing code. There is a mental aspect that trumps the physical. Re-writing is more of a mind set then it is a concept in programming. Sometimes things need to be re-written, they need to be forgotten, appreciated nonetheless but ultimately forgotten. Making something, like old code fit a new problem is limiting… re-writing is liberating.

I am 2 weeks into our Big Rewrite and feel so much better about Prospectlinker than ever. It’s time to make what is working better and to purge anything that is holding us back.

At the end of all of this I think Chad Fowler was right when he quoted the unrelated but ultimately insightful Martin Fowler,

The question to ask isn’t if you should refactor or rewrite your code, it’s when you should refactor or rewrite it.

So take the plunge and refactor something right now. Maybe a program, maybe an interface, maybe a plugin, maybe a gem, maybe a script, maybe even a relationship or work flow, anything at all that you feel is limiting you or limiting others. If you don’t do it now, the time will never come.

Good luck and as always, share your experiences with me so that I can learn and re-share them with others :)

Take care and have a great night,