Abstract
To improve software productivity, when constructing new software systems, programmers often reuse existing libraries or frameworks by invoking methods provided in their APIs. Those API methods, however, are often complex and not well documented. To get familiar with how those API methods are used, programmers often exploit a source code search tool to search for code snippets that use the API methods of interest. However, the returned code snippets are often large in number, and the huge number of snippets places a barrier for programmers to locate useful ones. In order to help programmers overcome this barrier, we have developed an API usage mining framework and its supporting tool called MAPO (Mining API usage Pattern from Open source repositories) for mining API usage patterns automatically. A mined pattern describes that in a certain usage scenario, some API methods are frequently called together and their usages follow some sequential rules. MAPO further recommends the mined API usage patterns and their associated code snippets upon programmers’ requests. Our experimental results show that with these patterns MAPO helps programmers locate useful code snippets more effectively than two state-of-the-art code search tools. To investigate whether MAPO can assist programmers in programming tasks, we further conducted an empirical study. The results show that using MAPO, programmers produce code with fewer bugs when facing relatively complex API usages, comparing with using the two state-of-the-art code search tools.
Access provided by Autonomous University of Puebla. Download to read the full chapter text
Chapter PDF
Similar content being viewed by others
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
References
Acharya, M., Xie, T., Pei, J., Xu, J.: Mining API patterns as partial orders from source code: From usage scenarios to specifications. In: Proc. 7th ESEC/FSE, pp. 25–34 (2007)
Aeschlimann, M., Baumer, D., Lanneluc, J.: Java tool smithing extending the Eclipse Java Development Tools. In: Proc. 2nd EclipseCon (2005)
Agrawal, R., Srikant, R.: Mining sequential patterns. In: Proc. 7th ICDE, pp. 3–14 (1995)
Alur, R., Černỳ, P., Madhusudan, P., Nam, W.: Synthesis of interface specifications for Java classes. In: Proc. 32nd POPL, pp. 98–109 (2005)
Ammons, G., Bodik, R., Larus, J.R.: Mining specifications. In: Proc. 29th POPL, pp. 4–16 (2002)
Angluin, D.: Learning regular sets from queries and counterexamples. Information and Computation 75(2), 87–106 (1987)
Ayres, J., Flannick, J., Gehrke, J., Yiu, T.: Sequential pattern mining using a bitmap representation. In: Proc. 8th KDD, pp. 429–435 (2002)
Bruch, M., Schäfer, T., Mezini, M.: FrUiT: IDE support for framework understanding. In: Proc. 4th ETX, pp. 55–59 (2006)
Chang, R., Podgurski, A., Yang, J.: Finding what’s not there: a new approach to revealing neglected conditions in software. In: Proc. ISSTA, pp. 163–173 (2007)
Engler, D., Chen, D.Y., Hallem, S., Chou, A., Chelf, B.: Bugs as deviant behavior: a general approach to inferring errors in systems code. In: Proc. 8th SOSP, pp. 57–72 (2001)
Gabel, M., Su, Z.: Javert: fully automatic mining of general temporal properties from dynamic traces. In: Proc. 16th FSE, pp. 339–349 (2008)
Google Code Search Engine (2008), http://www.google.com/codesearch
Han, J., Kamber, M.: Data mining: concepts and techniques. Morgan Kaufmann Publishers Inc., San Francisco (2000)
Henzinger, T., Jhala, R., Majumdar, R.: Permissive interfaces. In: Proc. 5th ESEC/FSE, pp. 31–40 (2005)
Holmes, R., Murphy, G.C.: Using structural context to recommend source code examples. In: Proc. 27th ICSE, pp. 117–125 (2005)
Holmes, R., Walker, R.J., Murphy, G.C.: Approximate structural context matching: An approach to recommend relevant examples. IEEE Transactions on Software Engineering 32(12), 952–970 (2006)
Hudson, R., Shah, P.: GEF in depth. In: Proc. 2nd EclipseCon (2005)
Jain, A.K., Murty, M.N., Flynn, P.J.: Data clustering: a review. ACM Computing Surveys 31(3), 264–323 (1999)
Li, Z., Zhou, Y.: PR-Miner: Automatically extracting implicit programming rules and detecting violations in large software code. In: Proc. 5th ESEC/FSE, pp. 306–315 (2005)
Livshits, V.B., Zimmermann, T.: Dynamine: Finding common error patterns by mining software revision histories. In: Proc. 5th ESEC/FSE, pp. 296–305 (2005)
Lo, D., Khoo, S.: SMArTIC: towards building an accurate, robust and scalable specification miner. In: Proc. 6th ESEC/FSE, pp. 265–275 (2006)
Mandelin, D., Xu, L., Bodik, R., Kimelman, D.: Jungloid mining: helping to navigate the API jungle. In: Proc. PLDI, pp. 48–61 (2005)
Matthew Scarpino, S.N., Holder, S., Mihalkovic, L.: SWT/JFace in Action. Manning (2005)
McCarey, F., Cinnéide, M.Ó., Kushmerick, N.: Recommending library methods: An evaluation of the vector space model (VSM) and latent semantic indexing (LSI). In: Proc. 9th ICSR, pp. 217–230 (2006)
Michail, A.: Data mining library reuse patterns using generalized association rules. In: Proc. 22nd ICSE, pp. 167–176 (2000)
Ng, T., Cheung, S., Chan, W., Yu, Y.: Work experience versus refactoring to design patterns: a controlled experiment. In: Proc. 6th ESEC/FSE, pp. 12–22 (2006)
Ramanathan, M.K., Grama, A., Jagannathan, S.: Path-sensitive inference of function precedence protocols. In: Proc. 29th ICSE, pp. 240–250 (2007)
Reiss, S., Renieris, M.: Encoding Program Executions. In: Proc. 23rd ICSE, pp. 221–230 (2001)
Saul, Z.M., Filkov, V., Devanbu, P., Bird, C.: Recommending random walks. In: Proc. 7th ESEC/FSE, pp. 15–24 (2007)
Scaffidi, C.: Why are APIs difficult to learn and use? Crossroads 12(4), 4–4 (2005)
Shoham, S., Yahav, E., Fink, S., Pistoia, M.: Static specification mining using automata-based abstractions. In: Proc. ISSTA, pp. 174–184 (2007)
Tansalarak, N., Claypool, K.T.: XSnippet: Mining for sample code. In: Proc. 21st OOPSLA, pp. 413–430 (2006)
Thummalapenta, S., Xie, T.: PARSEWeb: A programmer assistant for reusing open source code on the web. In: Proc. 22nd ASE, pp. 204–213 (2007)
Wasylkowski, A., Zeller, A., Lindig, C.: Detecting object usage anomalies. In: Proc. 7th ESEC/FSE, pp. 35–44 (2007)
Weimer, W., Necula, G.: Mining temporal specifications for error detection. In: Halbwachs, N., Zuck, L.D. (eds.) TACAS 2005. LNCS, vol. 3440, pp. 461–476. Springer, Heidelberg (2005)
Whaley, J., Martin, M., Lam, M.: Automatic extraction of object-oriented component interfaces. In: Proc. ISSTA, pp. 218–228 (2002)
Williams, C.C., Hollingsworth, J.K.: Recovering system specific rules from software repositories. In: Proc. 2nd MSR, pp. 1–5 (2005)
Xie, T., Pei, J.: MAPO: Mining API usages from open source repositories. In: Proc. 3rd MSR, pp. 54–57 (2006)
Yang, J., Evans, D., Bhardwaj, D., Bhat, T., Das, M.: Perracotta: mining temporal API rules from imperfect traces. In: Proc. 28th ICSE, pp. 282–291 (2006)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Zhong, H., Xie, T., Zhang, L., Pei, J., Mei, H. (2009). MAPO: Mining and Recommending API Usage Patterns. In: Drossopoulou, S. (eds) ECOOP 2009 – Object-Oriented Programming. ECOOP 2009. Lecture Notes in Computer Science, vol 5653. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03013-0_15
Download citation
DOI: https://doi.org/10.1007/978-3-642-03013-0_15
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-03012-3
Online ISBN: 978-3-642-03013-0
eBook Packages: Computer ScienceComputer Science (R0)