I think I'm slightly more defensive than average. I'm happy to let people dig in my code, but it makese me let my attachment to it go. I guess I'm the same way about cooking or anything, like if I'm doing it the way I love to do it, and somebody else wants to do it some other way, okay, fine, do it your way, that's cool, but I no longer really care about this food that we're making and I'm not going to be really passionately involved anymore. I detach.
I almost have a love affair with code that I have written for my own devices. Code that is uncluttered by all the ugly practicalities of error checking and multiple platforms and compilers; code that is clean and pure and simple and elegant. It makes me happy just to think about certain snippets, and sometimes I like to just go and "carress" them by changing a variable name or slightly cleaning up things, it's just a little visit to let the code know I still care. If someone else starts digging their dirty hands in my beautiful code, I feel like she has betrayed me. You slutty code, fooling around with other programmers, fine, fuck you, I'm leaving you, I no longer care about you. I might still use you but I will no longer tend and carress you, and over time you will get hacky and bloated and buggy and krufty because many hands are in you and no one is refactoring you.
I was thinking this morning about two of the horror story bosses that I had long ago. They shall remain anonymous to protect their privacy. At the time they drove me fucking batty insane, and I was too young and green to just quit or yell at them, but now I find it very amusing actually.
The first one was at this little company in one of my first jobs. The boss man was actually super nice, I liked him, but he was older and not really doing much coding any more, which was fine. The problem was he liked to hang out at the office really late and night and drink beers in his office and talk to people on the phone and watch movies and such. And he would go dig around the source code during these late night drunken office sessions. Often I would come in in the morning and find a bunch of changes in the code that were just like "WTF !?". It really drove me nuts until I figured out what was going on, and then after that I knew just to do a diff every morning when I got in and revert most of the changes that happened in the night. (I was actually a pretty terrible coder then and was writing tons of bugs, so some of his changes actually were fixes to my work).
The second was probably worse. You've surely had bosses who are "code style nazis" ; well I had a boss who was literally on the IEEE committee for code formatting style standards. When I started working he gave me like a 20 page document on how to format your code correctly, the number of tabs that should go here, how this should be aligned to that, etc. I was like "umm, okay" , skimmed it and threw it in the bin. Little did I know he expected exact compliance to every single rule on every line of code. He would review every check in that I made and send me lists of formatting errors. This was not even like code style safety issues or "defensive programming" or anything like that, it was entirely about variable naming conventions, number of tabs, spaces, etc. I quit after 3 months.