"Creating software programs" seem infinitely broad though, almost to the point of abstracting physical labor down to the "builds things with tools" level.
At the same time, I doubt that a carpenter, under UK law, would have to give up the house that he built in his spare time to the company that he works for, right? How does this not extend to software?
I've seen agreements before that attempted to lay claim to all work that you have done in the past and all work that you will do in the future. At the very least, I think that those are not enforceable.
However, the law doesn't operate in a vacuum. I suspect an employer is far more likely to lay claim to a piece of software which an employee claims was produced solely in his spare time than to lay claim to a house built by a carpenter it employs.
Further, for it to become a problem the employer has to become aware of the employee's work in their spare time. I suspect many problems arise where an employee creates a useful tool in their spare time, then uses it in their day job. The employee then leaves, but wishes to revoke rights in the tool, whereupon the employer then asserts that it owns the tool in question.
If however, the carpenter produced house plans as part of their work, then produced a separate plan in their spare time, the employer could potentially lay claim to that plan on the basis of the above case. If the carpenter produced a house to those plans they would likely be protected by s.51 CDPA '88 (but then unregistered design right infringement becomes an issue) but the underlying infringement of the employer's copyright would be still be an issue.
At the same time, the activities of the carpenter may breach other obligations in the employment contract, such as to not to be engaged by a third party whilst they are employed (this is of course irrelevant if for example the carpenter is constructing their own property to live in).
On your final point, an employee is not a consumer who has protections from unfair terms. If I as an employee are able to negotiate a remuneration package which reflects an assignment of all prior/future work then I can do so. As an employer I would have doubts as to whether such a transfer was possible/viable but that is not the same as saying it would not be enforceable.
- There has to be a meeting of the minds for a contract. If a contract is tipped too far to one side, it can be said that there is no consideration. In this example, if the employee is only getting what could be considered standard market rate for their employment as a software developer, the idea that all future work in software development (even past the term of employment) will belong to the company is absurd. The company is basically saying, "after you work for us, you are no longer allowed to work for anyone else as a software developer, ever."
- It may not be possible to grant copyright over all past work because it may be owned by a previous employer.
On the second point, the contract isn't unenforceable as a consequence of one party fraudulently/mistakenly attempting to give away something they are not in a position to.
If I'm the company, I take an indemnity from the developer which means I will be covered (well subject to the insurance/assets of the developer) if a previous employer attempts to assert its rights over IP I'm using. In the same way as it's the employee's decision to assign all rights, it's the company's decision to accept the assurances of the employee that the employee is in a position to assign.
If a company asserts that all employees must sign such a contract, I feel that it's pretty obvious that said company is just trying to make their contract as broad as possible to "cover all of the bases." They want to (attempt to) close all possible loopholes by essentially claiming "all your base are belong to us." How many software developers could even sign a contract that assigned over all IP rights to all IP that they ever created?
Unfortunately the phrase 'course of employment' has been held to have a broad meaning. The 1989 UK case of Missing Link Software v Magee held that where an employer could show that the work created was one that could be reasonably contemplated as part of the employee's duties, the employee would not have a claim to it. So if you're creating software programs in your spare time and your job description includes writing software programs, then the potential is that you wouldn't have a claim on them (although it depends on how closely the outside work is aligned to the work duties by the looks of things).
All the above doesn't require there to be any explicit clause in the agreement covering all IP rights. If there is such a clause, then I don't immediately see any reason why it would not be enforceable (although http://www.dyoung.com/article-ownership suggests the clause would be unenforceable).
All in all, I'd see a lawyer. If you want me to look at the agreement feel free to get in touch. I'm an in-house lawyer but will be able to give you some initial pointers and suggest a lawyer (I know a good firm in London who will provide an initial consultation for free).