> If you don't hate your code enough to throw it away and replace it on a whim, then you've made it more important than it should be.
You shouldn't write code you hate just to avoid attachment. What you should do instead is to develop the ability to (as product designers tend to say) "kill your darlings". You should love the code you create, but you should love the freedom even more that comes with being able to wipe it away with one stroke. Like sand drawings in a zen garden you should accept that nothing is ever final and don't let the things you created excert power over you.
You can also be proud of what you created as well, not because the thing is the thing it is, but because you made it and you were happy with how it turned out under the circumstances of the moment, maybe you even learned some things. Circumstances and the whole world change (including you), so what you created might not be up to the task anymore, you might be able to create something even better, more reduces, more clear, etc.
And you can feel all that while still happily throwing away your code. It is not a contradicition.