Skip to main content

Slicing Based Code Recommendation for Type Based Instance Retrieval

  • Conference paper
  • First Online:
Reuse in the Big Data Era (ICSR 2019)

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

Included in the following conference series:

Abstract

It is common for developers to retrieve an instance of a certain type from another instance of other types. However, it is quite often that developers do not exactly know how to retrieve the instance although they know exactly what they need (the instance to re retrieved, also known as the target instance) and where it could be retrieved (i.e., the source instance). Such kind of instance retrieval is popular and thus their implementations, in different forms, are often publicly available on the Internet. Consequently, a number of approaches have been proposed to retrieve such implementations (code snippets) and release developers from reinventing such snippets. However, the performance of such approaches deserves further improvement. To this end, in this paper, we propose a slicing based approach to recommending code snippets that could retrieve the target instance from the source instance. The approach works as follows. First, from a large code base, it retrieves methods that contain the source instance and the target instance. Second, for each of these methods, it locates the target instances, and extracts related code snippets that generate the target instances by backward code slicing. Third, from the extracted code snippets, it removes those that do not contain the source instance. Fourth, it merges code snippets whose corresponding target instances are at parallel execution paths. Fifth, it removes duplicate code snippets. Finally, it ranks the resulting code snippets, and presents the top ones. We implement the approach as an Eclipse plugin called TIRSnippet. We also evaluate it with real type based instance retrieval queries. Evaluation results suggest that compared to the state-of-the-art approaches, the proposed approach improves the precision and recall by 8.8%, and 25%, respectively.

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 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.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

References

  1. Bajracharya, S., et al.: Sourcerer: a search engine for open source code supporting structure-based search. In: Companion to the 21st ACM SIGPLAN Symposium on Object-Oriented Programming Systems, Languages, and Applications, pp. 681–682. ACM (2006)

    Google Scholar 

  2. D’Anjou, J., Fairbrother, S., Kehn, D., Kellerman, J., McCarthy, P.: The Java Developer’s Guide to Eclipse. Addison-Wesley Professional, Boston (2005)

    Google Scholar 

  3. Drori, O.: Algorithm for documents ranking: idea and simulation results. In: Proceedings of the 14th International Conference on Software Engineering and Knowledge Engineering, pp. 99–102. ACM (2002)

    Google Scholar 

  4. Grechanik, M., Fu, C., Xie, Q., McMillan, C., Poshyvanyk, D., Cumby, C.: A search engine for finding highly relevant applications. In: Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering, pp. 475–484. ACM (2010)

    Google Scholar 

  5. Gu, X., Zhang, H., Zhang, D., Kim, S.: Deep API learning. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, pp. 631–642. ACM (2016)

    Google Scholar 

  6. Henninger, S.: Retrieving software objects in an example-based programming environment. In: Proceedings of the 14th Annual International ACM SIGIR Conference on Research and Development in Information Retrieval, pp. 251–260. ACM (1991)

    Google Scholar 

  7. Holmes, R., Murphy, G.C.: Using structural context to recommend source code examples. In: Proceedings of the 27th International Conference on Software Engineering, pp. 117–125. IEEE (2005)

    Google Scholar 

  8. Hucka, M., Graham, M.J.: Software search is not a science, even among scientists. arXiv preprint arXiv:1605.02265 (2016)

  9. Jaskowski, W., Krawiec, K., Wieloch, B.: Multi-task code reuse in genetic programming. In: Proceedings of the 10th Annual Conference Companion on Genetic and Evolutionary Computation, pp. 2159–2164. ACM (2008)

    Google Scholar 

  10. Kim, K., et al.: FaCoY: a code-to-code search engine. In: Proceedings of the 40th International Conference on Software Engineering, pp. 946–957. ACM (2018)

    Google Scholar 

  11. Lv, F., Zhang, H., Lou, J.G., Wang, S., Zhang, D., Zhao, J.: CodeHow: effective code search based on API understanding and extended boolean model (e). In: Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering, pp. 260–270. IEEE (2015)

    Google Scholar 

  12. Mandelin, D., Xu, L., Bodík, R., Kimelman, D.: Jungloid mining: helping to navigate the API jungle. In: ACM SIGPLAN Notices, vol. 40, pp. 48–61. ACM (2005)

    Google Scholar 

  13. Mccabe, T.J.: A Complexity Measure. IEEE Press, Piscataway (1976)

    Book  Google Scholar 

  14. McMillan, C., Grechanik, M., Poshyvanyk, D., Xie, Q., Fu, C.: Portfolio: finding relevant functions and their usage. In: Proceedings of the 33rd International Conference on Software Engineering, pp. 111–120. ACM (2011)

    Google Scholar 

  15. Mishne, A., Shoham, S., Yahav, E.: Typestate-based semantic code search over partial programs. In: ACM SIGPLAN Notices, vol. 47, pp. 997–1016. ACM (2012)

    Google Scholar 

  16. Rahman, M.M., et al.: Evaluating how developers use general-purpose web-search for code retrieval. In: Proceedings of the 15th International Conference on Mining Software Repositories, pp. 465–475. ACM (2018)

    Google Scholar 

  17. Sahavechaphan, N., Claypool, K.: XSnippet: mining for sample code. In: ACM SIGPLAN Notices, vol. 41, pp. 413–430. ACM (2006)

    Google Scholar 

  18. Sim, S.E., Umarji, M., Ratanotayanon, S., Lopes, C.V.: How well do search engines support code retrieval on the web? ACM Trans. Softw. Eng. Methodol. (TOSEM) 21(1), 4 (2011)

    Article  Google Scholar 

  19. Stolee, K.T., Elbaum, S., Dobos, D.: Solving the search for source code. ACM Trans. Softw. Eng. Methodol. (TOSEM) 23(3), 26 (2014)

    Article  Google Scholar 

  20. Thummalapenta, S., Xie, T.: Parseweb: a programmer assistant for reusing open source code on the web. In: Proceedings of the 22nd IEEE/ACM International Conference on Automated Software Engineering, pp. 204–213. ACM (2007)

    Google Scholar 

  21. Ye, Y., Fischer, G.: Supporting reuse by delivering task-relevant and personalized information. In: Proceedings of the 24th International Conference on Software Engineering, pp. 513–523. ACM (2002)

    Google Scholar 

Download references

Acknowledgments

The work is supported by the National Key Research and Development Program of China (2016YFB1000801), and the National Natural Science Foundation of China (61690205, 61772071).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hui Liu .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Sun, R., Liu, H., Li, L. (2019). Slicing Based Code Recommendation for Type Based Instance Retrieval. In: Peng, X., Ampatzoglou, A., Bhowmik, T. (eds) Reuse in the Big Data Era. ICSR 2019. Lecture Notes in Computer Science(), vol 11602. Springer, Cham. https://doi.org/10.1007/978-3-030-22888-0_11

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-22888-0_11

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-22887-3

  • Online ISBN: 978-3-030-22888-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics