Agreed. A pharma company can't complain of patent infringement because you create a drug that treats the same disease. They can only complain if it's the same drug.
Only the actual technique (e.g. a specific algorithm) should be patentable (and obviously any actual code has protection under copyright law). Not general nonsense like "a flash player embedded in a web browser can play without user interaction" leading to the "click to activate and use control" nonsense (that said there could be security benefits to that example...).
I think perhaps there should be a legal test applied, along the lines of "is it so blinding obvious a chimpanzee could come up with it?", before a patent is issued.