One of the problems in writing good code is a reluctance to back up. An example —
I was writing a little app for a client the other day, and I had a written some PHP to split an unordered list (UL) into three columns. Then I needed this code on another page…so I cut-and-pasted it in. Then I needed it in another page…so I did that again.
And this is how it happens — you start cut-and-pasting code all over the place, DRY be damned.
Why do we do this? I think I figured out why today: we don’t like to back up.
For me to do things right and fix my code, I would have had to cease forward progress and back up a step. I would have needed to figure out a way to encapsulate that code, put it somewhere where other code could get at it, change my existing references to call the new code, and debug the results.
And we don’t like to do this. We don’t like to abandon forward progress even if the end result is better.
I don’t have an answer for this, really, but writing it at least helps put it in perspective.