|laziness, impatience, and hubris|
One problem with all of this is the impossibility of keeping your employer constantly updated on what you are doing.
I have written several programs in a single day, and it could be a bit hard to keep them updated all the time on what I was doing. The whole idea is nuts.
Aside: Everyone should do is check their state's coercion laws. In some states, being forced to sign a contract to get a job is considered duress.
Dealing with code sharing at work
Almost all of my employment contracts have limited the company's IP claims to work I did specifically for them. So far no company has contested work I did on their equipment and time. Of course, I've always told them what I was doing. A lot of companies are far too lax about this. I often asked for a more formal arrangement than my employer did.
I have both taken my own code and used it at work, and used code from work elsewhere. I documented what I did, made sure my company knew, and developed a few habits along the way that seem to help.
The first conflict I had was because I worked on classified systems, and needed to move code in and out. I learned to sanitize code, and move useful code without giving away proprietary information. It had to pass a review before leaving. Bringing code in was usually pretty easy.
I can't say enough how writing clean and modular code makes this whole process much easier.
Never keep what you are doing quiet. While I have had to take this approach before, it is far better to document what you do and make sure people know it. Don't be ambiguous: be explicit about what you are doing and what you intend to do, and what rights you want them to have.
For any code that I gave my employer, I made sure it was copyrighted and also had a license granting them unrestricted use. This is very important. You really can screw things up for your employer if you are ambiguous about their rights to your work.
So far, most employers I've had were happy to find I already had code which could do the job. Unfortunately many of them are way to careless with copyrighted information. In some ways I have had the opposite problem from what Tilly had.
Everyone should also spend some time researching ideas like "shop rights", where you own all code you write, regardless of employment, and grant your employer full rights to use the code.
IMHO, it is very rare that an employer should find this unacceptable. It gives them all the rights they need, and you retain your natural right to what you create. Obviously there are issues regarding internal/secret/patented information, but reasonable people can work that out.