What we are isn't limited to what's inside our body and brain. The objects we interact with also count to an extent. (Being a cellist, makes me acutely aware of that.) What counts the most is any information stored in those objects, especially information you can't retrieve elsewhere —notes, journal, and other such personal data. Losing that information is like losing a memory. Being stored in a hard drive, a paper book, or a human brain doesn't make much of a difference.[1]
So, when I write some code for a company, I have the right to remember it, and I will exercise that right. That's basic human dignity. If our current power structure (err, "legal system") says otherwise, then it should be reformed.
On the other hand, I can restrain myself, and avoid to disclose all those memories, say, in a public SVN repository. I don't like to keep secrets, but let's face it, I already do, and it doesn't bother me too much. So, I treat corporate copyright as a form of non-disclosure agreement: I won't tell anyone.
But I will remember.
---
[1] looong footnote:
Really it doesn't. One day, it may even make no difference at all. We don't have the technology yet, but imagine having a computer wired to our nervous system. It could act as a pair of Google glasses 5.0, or augment our intellect more directly: more working memory, more and more accurate term memories on silicon, even perfect recall.
Now you can't even make the difference between neuron memories and silicon memories. They're both equally a part of you. Heck, your whole brain could be turned into silicon, it probably wouldn't make any difference. (I happen to believe in "mind uploading". I won't justify why here.)
Now let an employer ask you to delete whatever copy of the code you may still hold. Now it is quite literally asking you to erase part of your memories. What exactly should you erase, anyway? Just enough to disable perfect recall? Keep whatever happens to be stored in neurons, and erase whatever is in the silicon part? What if you have stored everything about that company in silicon? (You may well have, if perfect recall makes you more productive, and requires silicon memory.)
If we had the technical means right now, I believe Goldman Sachs would have us forget everything we learned while working within their walls, if not more —like in the Paycheck movie (2003). I think we can all agree it wouldn't be acceptable.