The reality is, code is the collective memory of a programmer. Most software devs always keep copies of their work, usually not to resell or reuse (you can't and shouldn't, unless you're an idiot and want to end up like this guy), but more as a reference (How did I do that? I had an example somewhere).
I don't have a copy of the software I worked on at my last two employers and would consider taking a copy before I left a gross breach of trust.
I have a copy of work I've done while self-employed, as I can't expect non-technical customers to carefully look after their source code.