In the introduction to The Gay Science, Friedrich Nietzsche famously compared writing to giving birth:
"[W]e have to give birth to our thoughts out of our pain and, like mothers, endow them with all we have of blood, heart, fire, pleasure, passion, agony, conscience, fate, and catastrophe."
Ever feel that way about your code? You shouldn't.
Your code is not your baby. It's not living, it's not breathing, and frankly it doesn't deserve much fawning over. And worse, getting attached to your code at that level will make you a worse developer.
- When your code is your baby, emotional reactions trump rational actions.
- When your code is your baby, you don't want to change it.
- When your code is your baby, you resist other people's attempts to make it better.
- When your code is your baby, you fail to see its shortcomings.
- When your code is your baby, what it does takes a back seat to what it is (to you).
Your code is just your code. Nietzsche is wrong -- or at least guilty of gross hyperbole. Transforming your thoughts to words may cause a certain amount of psychological pain, and you might indeed pour your creativity into every line. But at the end of the day, you have an object that performs a function. Treat it that way, and you will have the freedom to make it better.