This is actually a good point. In XP this is one of the reasons you do spikes. Often you will throw away all of your rigour when you do a spike and just see what comes out the other side. Then you throw away the code and reimplement it using your rigour. That way you get the best of both worlds with a small penalty of having to do some rewrites. It takes a considerable amount of discipline, though, to throw away working code when people are screaming at you to deliver ;-)