There's so many so trivial patents on obvious software-techniques today that it's virtually guaranteed that any software above a certain complexity-treshold will infringe on a number of them.
There is precisely no way at all to write a non-trivial program, and be reasonably sure that you can legally sell it, without infringing any patent.
Thus the best thing you can do about it is either not to write programs, or to do so while ignoring patents alltogether and hoping for the best.