Spawned by the misconception that software is going to be controllable, software patents can be applied for when a piece of code does something unique. What exactly is this something unique? That is the problem. First of all, even if things like that could be defined in concrete terms the industry moves too fast for a system like the patent office uses to arbitrate them. Personally, I don't think software can be or should be patented. But most companies care more about profit than doing what is right, so software patents are probably just something we are going to have to deal with, even though they violate the common sense belief in freedom of thought.