If software is to be patented, I think sourcecode should be provided and sealed in a vault (digital and/or physical) until the patent expires, then that sourcecode becomes public domain.
Making patents secret is the wrong approach. Seal patents in a vault and there's no way to find out if your code is infringing on the patent outside of a lawsuit.