It would be interesting to have a system where getting a software patent required publishing working code under public domain. Then when the patent expires, it's open for all.
Which is arguably the point: the patent term should cover the likely amount of time that commercial exploitation is most advantaged by a government granted temporary monopoly. Obsolescence is pretty clearly a point where commercial exploitation is (severely) disadvantaged. The goal for patents was that for that temporary leg up (and today's 20 years starts to feel a lot less temporary) the company had to make all the information and science and schematics public domain. It's not a bad idea that if software/software algorithms are patentable the actual code should fall under that public domain disclosure. The balancing act that remains is the question of how much code is "schematics" and how much of it is "final product" and how much protection products deserve versus schematics...