What you are looking for is Freedom-to-Operate. There are quite a few articles written on this subject, and most of them deal with the inherent difficulty you describe. I've stitched together some excerpts from those articles, hopefully into a coherent meta-article:
Crouch, D. Facilitating Freedom-to-Operate Searches. Patently-O. September 17, 2010.
A good freedom-to-operate (FTO) search will include a search of
pending patent applications with an eye toward potential future
Quinn, G. Difference Between Patent Searches & Infringement Clearance. IP Watchdog. January 21, 2010
...it is impossible to determine whether [a] device would infringe
without obtaining the complete file history of each patent that is
close. You simply cannot tell from reading a patent whether a device
will infringe. This is because everything in the file history, all the
arguments made to the examiner and papers filed work to either narrow
or expand the definition and meaning of terms in the patent
Sutton, P. Patent-FTO caveats. World Intellectual Property Review. January 2, 2014.
There is no substitute for retaining highly skilled and experienced
patent counsel to advise on the avoidance and mitigation of such
Quinn, G. Freedom to Operate: Knowing if you will likely infringe a patent. IP Watchdog. June 27, 2015.
...the search for a freedom to operate opinion would alone cost at
least $3,000, and that would return dozens of references that a patent
attorney must wade through in painstaking detail. Typically a freedom
to operate opinion will cost at least $10,000, and sometimes
substantially more. It is not at all uncommon for a freedom to operate
opinion to cost $20,000 or $30,000, or more.
Thayer, L. J. When Is a "Freedom to Operate" Opinion Cost-Effective? Today’s General Counsel. February/March 2013.
As a first step, a company should consider the product or service
being launched or acquired in terms of its value to the company.
Products with high margin or high volume are most likely to lead to
high damage awards if a patent-infringement case goes to trial.
Therefore it will often be worth it to take the extra step and clear
the product before proceeding. ... If a company has limited dollars
to spend for clearance, products can at least be initially ranked in
terms of value.
... For products requiring less investment, FTO analysis may be deferred until nearer to the end of the project, but it should still be performed before release.
The danger of waiting until the product is fully developed lies in a
simple fact: By then the business units will be champing at the bit to
release the product, and an early release may result in litigation
that was avoidable.
Lundberg, S. Are Software Patent FTO’s Really that Hard to Do?: Are Software Patents Impossible to Index, or is No One Trying? Patents4Software. March 10, 2012.
If software patents were a minefield for developers, the mines would
generally be at least 5 miles apart, making accidentally stepping on
one a very low probability occurrence. If it is a patent on “internal
functionality” that would not normally be discernible by observing the
software operate or using it, the odds of the patent owner finding out
you stepped on their mine are smaller yet.
Essentially, what this boils down to is a risk assessment. If you are founding a startup, you might build this into the commercialization plan as a potential risk, and identify any parts of the code base that may need to be analyzed for freedom-to-operate. If/when the company is acquired or funded by VC, a proper freedom-to-operate search can be done at that time.
As a developer, you should be aware of a few basic guidelines: if you are using algorithms and methods that have been around for 17 to 20 years, then all patent claims should have expired by now. If you are using libraries or frameworks from Open Source or licensed commercial software, then those pieces should also be in the clear. What is left over is material that could be at risk for freedom-to-operate.
If you want to adjust your software development approach to accommodate potential future-discovered freedom-to-operate issues, then make it as easy as possible to accommodate multiple methods of solving a problem wherever you find at-risk code. There is almost always more than one way to accomplish a task in software, and it is usually pretty easy to side-step patent claims by adjusting your approach, if it is ever required in the future. Accommodating multiple approaches is made far easier by adopting good software development practices, namely keep your code base clean, well-documented and modular (encapsulate code to make it easy to analyze in small pieces).
There is currently draft legislation on patent reform to address some of these issues. The Electronic Frontier Foundation keeps an updated list of the proposed reforms, and many of them contain language to specifically protect startup companies against patent trolls.
SHIELD Act (HR 6245)
Reps. Peter DeFazio (D-OR) and Jason Chaffetz (D-UT)
The SHIELD Act, or the Saving High-Tech Innovators from Egregious
Legal Disputes Act (H.R. 845), is designed to help the innocent
victims of patent trolls by creating a "fee shifting" system.
To put the current state of software patents in perspective, the following book (relevant pages available online) describe the historical decisions on software patents, including relatively recent changes from AIA:
The Changing Face of US Patent Law and Its Impact on Business Strategy. Cahoy, D.R. and Oswald, L.J., eds. Edward Eglar, United Kingdom, 2013; pp44-49.