Friday, February 3, 2012

Testing to ensure code gets cleaned up.

The other day I was working on a change on www.checkthesock.com that involved getting rid of some pages. It is generally a good idea to redirect those URL's to a relevant location so that search engines and people can get to a useful location. Eventually no one uses the old URL anymore and whatever code is redirecting it is just sitting around gathering dust.

I wanted to make sure I eventually cleaned up the code I had doing the redirection. In the past I have tried several different ways of remembering to do this; try to remember, put a note somewhere, or put a reminder in my calendar. None of those have ever ended up working out. None of those methods involve anything that is part of my normal working process.

The solution I came up with was to write a test that checks to see if the code is still around at some future date. I run my tests all the time as part of my normal workflow and I never release code without fixing a broken test. Now at some future point in time the test will break and I will not forget to clean up my unused code. Seems like a potentially useful pattern. In a few months, when my tests start breaking to remind me to clean stuff up, I will discover if it is useful or just really annoying.

2 comments:

Kamalesh Kumar said...

Exciting post and thank you for sharing. There are things here that I didn't think some time as of late. Because of cool such a position, to the point that is to a great degree carefully taken, we will talk a huge amount of colleagues about it.Outdoor Advertising Agencies in Nagpur

Oracle Fusion said...

Excellent blog after reading this I am impressed a lot. Thank you so much We provide online classes for oracle courses. We have reference site. Please go through it.
Oracle Fusion HCM Technical Training