The primary goal of software development is to deliver Optimal Software, i.e., software produced at low cost, high quality & productivity and scheduled with in time. In order to achieve this optimal software, programmers generally reuse the existing libraries, rather than developing similar code products right from the scratch. While reusing the libraries, programmers are facing several changes such as many existing libraries are not properly documented and many libraries contain large number of program interfaces (PIs) through which libraries expose their functionality. These challenges lead to certain problems that affect in producing optimal software. The problems such as reuse of existing libraries consumes more time, lack of knowledge on reusage of program interfaces and we can’t generate effective test inputs during white box testing. The first two problems reduce the software productivity where as last one affect on software testing. To resolve these problems, we propose a general framework called Netminer. Netminer contains a code search engine. With the help of code search engine, we can search the available open source code over the internet. In the analysis phase, Netminer automatically compares the specifications of program interfaces with relevant code examples that are available in the internet. In the next phase, Netminer applies data mining techniques on code examples that are collected and identify common patterns. The common patterns represent exact usage of program interfaces. We propose some more approaches based on Netminer. Some approaches help programmers in effectively reusing program interfaces provided by existing libraries. Some approaches identify defects under analysis from the mined specifications and some approaches help in generating test inputs by the use of static and dynamic test generation. Our research study shows that Netminer framework can be effectively used in software engineering for achieving optimal software.