Monday, April 03, 2006

The copy and paste anti-pattern

I've just picked up somebody else's ASP.NET 1.1 application and like probably every developer who's picked up somebody else's code, I think it's crap. The thing that worries me most is how hard it is to create a new page. I create a new web form and then I have to copy and paste the markup form another page. Then I need to go through and add a bit of code to the code behind file. ASP.NET provides lots of mechanisms to avoid having to do this (as does pretty much every other web development platform). We have page inheritance, so common code can be put in a parent class. We have user controls, so bits of repeated HTML can be put in them. OK, a bit of setting up of a new page may well be necessary but copying and pasting, whether markup or code, is a very bad sign. When the change request comes through (as it always does) to redesign the whole site, if every single file needs to be modified, life will be very painful.

No comments: