I recently stumbled upon a great article about the attachment one programmer can have with his/her code.
The article states:
Criticism to your code is not a criticism to you. Just because you wrote a crap code in the past, for whatever reason, that doesn’t mean you’re a crap developer. The code is crap, not you. You never were.
That reminded me a variation of this, which an old colleague used to say to me:
Do not identify yourself with your project or code. Your project will be criticized, abandoned, scheduled for removal, or plain ignored because business has shifted while you worked. Moreover, it is an exercise for when you will need to sell or defend the work of those you will manage.
It turns out Jeff Atwood have also written about this.
These quotes have proven useful a lot of times in my career, and have improved my life as a software engineer.
Do your best, but don’t get too attached to your work!