Skip to main content

MAPO: Mining and Recommending API Usage Patterns

  • Conference paper
Book cover ECOOP 2009 – Object-Oriented Programming (ECOOP 2009)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 5653))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Google Scholar 

  2. Aeschlimann, M., Baumer, D., Lanneluc, J.: Java tool smithing extending the Eclipse Java Development Tools. In: Proc. 2nd EclipseCon (2005)

    Google Scholar 

  3. Agrawal, R., Srikant, R.: Mining sequential patterns. In: Proc. 7th ICDE, pp. 3–14 (1995)

    Google Scholar 

  4. Alur, R., Černỳ, P., Madhusudan, P., Nam, W.: Synthesis of interface specifications for Java classes. In: Proc. 32nd POPL, pp. 98–109 (2005)

    Google Scholar 

  5. Ammons, G., Bodik, R., Larus, J.R.: Mining specifications. In: Proc. 29th POPL, pp. 4–16 (2002)

    Google Scholar 

  6. Angluin, D.: Learning regular sets from queries and counterexamples. Information and Computation 75(2), 87–106 (1987)

    Article  MathSciNet  MATH  Google Scholar 

  7. Ayres, J., Flannick, J., Gehrke, J., Yiu, T.: Sequential pattern mining using a bitmap representation. In: Proc. 8th KDD, pp. 429–435 (2002)

    Google Scholar 

  8. Bruch, M., Schäfer, T., Mezini, M.: FrUiT: IDE support for framework understanding. In: Proc. 4th ETX, pp. 55–59 (2006)

    Google Scholar 

  9. 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)

    Google Scholar 

  10. 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)

    Google Scholar 

  11. Gabel, M., Su, Z.: Javert: fully automatic mining of general temporal properties from dynamic traces. In: Proc. 16th FSE, pp. 339–349 (2008)

    Google Scholar 

  12. Google Code Search Engine (2008), http://www.google.com/codesearch

  13. Han, J., Kamber, M.: Data mining: concepts and techniques. Morgan Kaufmann Publishers Inc., San Francisco (2000)

    MATH  Google Scholar 

  14. Henzinger, T., Jhala, R., Majumdar, R.: Permissive interfaces. In: Proc. 5th ESEC/FSE, pp. 31–40 (2005)

    Google Scholar 

  15. Holmes, R., Murphy, G.C.: Using structural context to recommend source code examples. In: Proc. 27th ICSE, pp. 117–125 (2005)

    Google Scholar 

  16. 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)

    Article  Google Scholar 

  17. Hudson, R., Shah, P.: GEF in depth. In: Proc. 2nd EclipseCon (2005)

    Google Scholar 

  18. Jain, A.K., Murty, M.N., Flynn, P.J.: Data clustering: a review. ACM Computing Surveys 31(3), 264–323 (1999)

    Article  Google Scholar 

  19. 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)

    Google Scholar 

  20. Livshits, V.B., Zimmermann, T.: Dynamine: Finding common error patterns by mining software revision histories. In: Proc. 5th ESEC/FSE, pp. 296–305 (2005)

    Google Scholar 

  21. Lo, D., Khoo, S.: SMArTIC: towards building an accurate, robust and scalable specification miner. In: Proc. 6th ESEC/FSE, pp. 265–275 (2006)

    Google Scholar 

  22. Mandelin, D., Xu, L., Bodik, R., Kimelman, D.: Jungloid mining: helping to navigate the API jungle. In: Proc. PLDI, pp. 48–61 (2005)

    Google Scholar 

  23. Matthew Scarpino, S.N., Holder, S., Mihalkovic, L.: SWT/JFace in Action. Manning (2005)

    Google Scholar 

  24. 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)

    Google Scholar 

  25. Michail, A.: Data mining library reuse patterns using generalized association rules. In: Proc. 22nd ICSE, pp. 167–176 (2000)

    Google Scholar 

  26. 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)

    Google Scholar 

  27. Ramanathan, M.K., Grama, A., Jagannathan, S.: Path-sensitive inference of function precedence protocols. In: Proc. 29th ICSE, pp. 240–250 (2007)

    Google Scholar 

  28. Reiss, S., Renieris, M.: Encoding Program Executions. In: Proc. 23rd ICSE, pp. 221–230 (2001)

    Google Scholar 

  29. Saul, Z.M., Filkov, V., Devanbu, P., Bird, C.: Recommending random walks. In: Proc. 7th ESEC/FSE, pp. 15–24 (2007)

    Google Scholar 

  30. Scaffidi, C.: Why are APIs difficult to learn and use? Crossroads 12(4), 4–4 (2005)

    Article  Google Scholar 

  31. Shoham, S., Yahav, E., Fink, S., Pistoia, M.: Static specification mining using automata-based abstractions. In: Proc. ISSTA, pp. 174–184 (2007)

    Google Scholar 

  32. Tansalarak, N., Claypool, K.T.: XSnippet: Mining for sample code. In: Proc. 21st OOPSLA, pp. 413–430 (2006)

    Google Scholar 

  33. Thummalapenta, S., Xie, T.: PARSEWeb: A programmer assistant for reusing open source code on the web. In: Proc. 22nd ASE, pp. 204–213 (2007)

    Google Scholar 

  34. Wasylkowski, A., Zeller, A., Lindig, C.: Detecting object usage anomalies. In: Proc. 7th ESEC/FSE, pp. 35–44 (2007)

    Google Scholar 

  35. 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)

    Chapter  Google Scholar 

  36. Whaley, J., Martin, M., Lam, M.: Automatic extraction of object-oriented component interfaces. In: Proc. ISSTA, pp. 218–228 (2002)

    Google Scholar 

  37. Williams, C.C., Hollingsworth, J.K.: Recovering system specific rules from software repositories. In: Proc. 2nd MSR, pp. 1–5 (2005)

    Google Scholar 

  38. Xie, T., Pei, J.: MAPO: Mining API usages from open source repositories. In: Proc. 3rd MSR, pp. 54–57 (2006)

    Google Scholar 

  39. 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)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics