Massive refactoring

or “why I love unit tests”. An ode to agile software development. :-)

It is becoming a theme on this blog, but you are just going to have to deal with it. Earlier this week I completed a massive refactoring of an application and I am still amazed at how easy that went.

What is a refactoring? From Wikipedia:

Code refactoring is the process of changing a computer program’s internal structure without modifying its external behavior or existing functionality. This is usually done to improve code readability, simplify code structure, change code to adhere to a given programming paradigm, improve maintainability, or improve extensibility.

In other words: change. Usually, changing a live application is a nightmare. Who knows what will break? With for example a PHP site you cannot know this beforehand. And so very often the code is either not changed or a huge problems are introduced.

For radio 1 I completely refactored the Podcasts and Fragments pages and I did it in three days without anything breaking. About a third of the website changed on the inside, but nothing changed on the outside. The Podcast model even changed 90% and the accompanying database table was dropped, in lieu of a Single Table Inheritance model. Each of these things are huge by itself. All pages continued to work and the new things simply got added.

I do not know how I could have do that without an automated test suite. I do not (want to) know how PHP or .Net people do such things. (I fear they often ‘hope for the best’)

So thank you Ruby on Rails and RSpec for making this possible.

  1. No comments yet.

  1. No trackbacks yet.