Friday, February 3, 2012

Testing to ensure code gets cleaned up.

The other day I was working on a change on 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.


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

Rajesh said...

Thanks for sharing great information, Hope you will share many more articles so that it will be helpful for many of us.

Oracle Fusion Financials Online Training

oraclefusionapplications said...

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.
oracle fusion financials online training

murali krishna said...

Awesome post……. your article is really informative and helpful for me and other bloggers too

Oracle Fusion HCM Online Training

shivani said...

Astonishing web diary I visit this blog it's incredibly magnificent. Strangely, in this blog content made doubtlessly and sensible. The substance of information is instructive.
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training