This Article 
 Bibliographic References 
 Add to: 
Approximate Structural Context Matching: An Approach to Recommend Relevant Examples
December 2006 (vol. 32 no. 12)
pp. 952-970
Gail C. Murphy, IEEE Computer Society
When coding to an application programming interface (API), developers often encounter difficulties, unsure of which class to subclass, which objects to instantiate, and which methods to call. Example source code that demonstrates the use of the API can help developers make progress on their task. This paper describes an approach to provide such examples in which the structure of the source code that the developer is writing is matched heuristically to a repository of source code that uses the API. The structural context needed to query the repository is extracted automatically from the code, freeing the developer from learning a query language or from writing their code in a particular style. The repository is generated automatically from existing applications, avoiding the need for handcrafted examples. We demonstrate that the approach is effective, efficient, and more reliable than traditional alternatives through four empirical studies.

[1] H.A. Basit and S. Jarzabek, “Detecting Higher-Level Similarity Patterns in Programs,” Proc. European Conf. Software Eng. and ACM SIGSOFT Int'l Symp. Foundations of Software Eng., pp. 156-165, 2005.
[2] I.D. Baxter, A. Yahin, L.M.D. Moura, M. Sant'Anna, and L. Bier, “Clone Detection Using Abstract Syntax Trees,” Proc. Int'l Conf. Software Maintenance, pp. 368-377, 1998.
[3] G. Butler and P. Dénommée, “Documenting Frameworks,” Building Application Frameworks: Object-Oriented Foundations of Framework Design, chapter 21, 1999.
[4] D. Čubranić, G.C. Murphy, J. Singer, and K.S. Booth, “Hipikat: A Project Memory for Software Development,” IEEE Trans. Software Eng., vol. 31, no. 6, pp. 446-465, 2005.
[5] G. Froehlich, H.J. Hoover, L. Liu, and P. Sorenson, “Hooking into Object-Oriented Application Frameworks,” Proc. Int'l Conf. Software Eng., pp. 491-501, 1997.
[6] R. Helm, I.M. Holland, and D. Gangopadhyay, “Contracts: Specifying Behavioral Compositions in Object-Oriented Systems,” Proc. European Conf. Object-Oriented Programming and ACM Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 169-180, 1990.
[7] S. Henninger, “Retrieving Software Objects in an Example-Based Programming Environment,” Proc. ACM SIGIR Int'l Conf. Research and Development in Information Retrieval, pp. 251-260, 1991.
[8] R. Hill and J. Rideout, “Automatic Method Completion,” Proc. IEEE Int'l Conf. Automated Software Eng., pp. 228-235, 2004.
[9] R. Holmes, “Using Structural Context to Recommend Source Code Examples,” master's thesis, Univ. of British Columbia, 2004.
[10] R. Holmes and G.C. Murphy, “Using Structural Context to Recommend Source Code Examples,” Proc. Int'l Conf. Software Eng., pp. 117-125, 2004.
[11] K. Inoue, R. Yokomori, H. Fujiwara, T. Yamamoto, M. Matsushita, and S. Kusumoto, “Component Rank: Relative Significance Rank for Software Component Search,” Proc. Int'l Conf. Software Eng., pp. 14-24, 2003.
[12] R.E. Johnson, “Documenting Frameworks Using Patterns,” Proc. ACM Conf. Object-Oriented Programming, Systems, Languages, and Applications, pp. 63-72, 1992.
[13] D. Mandelin, L. Xu, R. Bodík, and D. Kimelman, “Jungloid Mining: Helping to Navigate the API Jungle,” Proc. ACM Conf. Programming Language Design and Implementation, pp. 48-61, 2005.
[14] A. Michail, “Data Mining Library Reuse Patterns Using Generalized Association Rules,” Proc. Int'l Conf. Software Eng., pp. 167-176, 2000.
[15] A. Michail, “Code Web: Data Mining Library Reuse Patterns,” Proc. Int'l Conf. Software Eng., pp. 827-828, 2001.
[16] L.R. Neal, “A System for Example-Based Programming,” Proc. SIGCHI Conf. Human Factors in Computing Systems, pp. 63-68, 1989.
[17] S. Paul, “SCRUPLE: A Reengineer's Tool for Source Code Search,” Proc. IBM Centre for Advanced Studies Conf., pp. 329-346, 1992.
[18] E. Rissland, “Examples and Learning Systems,” Adaptive Control of Ill-Defined Systems, 1983.
[19] M.B. Rosson and J.M. Carroll, “The Reuse of Uses in Smalltalk Programming,” ACM Trans. Computer-Human Interaction, vol. 3, no. 3, pp. 219-253, 1996.
[20] Y. Ye, G. Fischer, and B. Reeves, “Integrating Active Information Delivery and Reuse Repository Systems,” Proc. ACM SIGSOFT Int'l Symp. Foundations of Software Eng., pp. 60-68, 2000.
[21] Y. Ye and G. Fischer, “Supporting Reuse by Delivering Task-Relevant and Personalized Information,” Proc. Int'l Conf. Software Eng., pp. 513-523, 2002.
[22] A.M. Zaremski and J.M. Wing, “Signature Matching: A Tool for Using Software Libraries,” ACM Trans. Software Eng. and Methodology, vol. 4, no. 2, pp. 146-170, 1995.

Index Terms:
API usage, structural context, heuristic search, Strathcona, example recommendation.
Reid Holmes, Robert J. Walker, Gail C. Murphy, "Approximate Structural Context Matching: An Approach to Recommend Relevant Examples," IEEE Transactions on Software Engineering, vol. 32, no. 12, pp. 952-970, Dec. 2006, doi:10.1109/TSE.2006.117
Usage of this product signifies your acceptance of the Terms of Use.