IEEE TRANSACTIONS ON SOFTWARE ENGINEERING, 2011 1 Two Studies of Framework-Usage Templates Extracted from Dynamic Traces Abbas Heydarnoori, Krzysztof Czarnecki, Walter Binder, and Thiago Tonelli Bartolomei Abstract—Object-oriented frameworks are widely used to develop new applications. They provide reusable concepts that are instantiated in application code through potentially complex implementation steps such as subclassing, implementing interfaces, and calling framework operations. Unfortunately, many modern frameworks are difficult to use because of their large and complex APIs and frequently-incomplete user documentation. To cope with these problems, developers often use existing framework applications as a guide. However, locating concept implementations in those sample applications is typically challenging due to code tangling and scattering. To address this challenge, we introduce the notion of concept-implementation templates, which summarize the necessary concept-implementation steps and identify them in the sample application code, and a technique, named FUDA, to automatically extract such templates from dynamic traces of sample applications. This article further presents the results of two experiments conducted to evaluate the quality and usefulness of FUDA templates. The experimental evaluation of FUDA with 14 concepts in five widely-used frameworks suggests that the technique is effective in producing templates with relatively few false positives and false negatives for realistic concepts by using two sample applications. Moreover, we observed in a user study with 28 programmers that the use of templates reduced the concept-implementation time compared to when documentation was used. Index Terms—Object-oriented application frameworks, framework comprehension, framework documentation, concept- implementation templates, application programming interface (API), dynamic analysis, concept location, feature identification. 1 I NTRODUCTION O BJECT- ORIENTED APPLICATION FRAMEWORKS have shown to be one of the most effective reuse tech- nologies available today, enabling reuse of both design and code [1]. Frameworks provide domain-specific concepts, which are generic units of functionality. Framework-based applications are constructed by writing application code, which instantiates these concepts. For example, the Eclipse framework offers concepts such as tree viewers and text editors. Eclipse’s Ant View and Java Editor are instances of these concepts. The instantiation of such concepts requires following different implementation steps in the application code, such as subclassing framework-provided classes, im- plementing interfaces, and calling appropriate framework methods. These steps are governed by the framework’s application programming interface (API). Unfortunately, many existing frameworks are difficult to use because of their large and complex APIs and often incomplete user documentation [2]. To ease these problems, developers frequently use existing framework applications as a guide to understand how to implement a desired concept [1]. However, locating the concept implementation in existing applications can be a challenge because its implementation is often scattered across the source code A. Heydarnoori and W. Binder are with the Faculty of Informatics, University of Lugano, Via Giuseppe Buffi 13, 6904 Lugano, Switzerland. E-mail: {abbas.heydarnoori, walter.binder}@usi.ch K. Czarnecki and T.T. Bartolomei are with the Department of Electrical and Computer Engineering, University of Waterloo, Waterloo, Ontario, Canada. Email: {kczarnec, ttonelli}@gsd.uwaterloo.ca and tangled with the code implementing other concepts. To cope with this challenge, feature location and identification techniques such as PROMESIR [3], SNIAFL [4], and SITIR [5] can be used to locate the parts of the application source code implementing a functionality of interest, spec- ified by usage scenarios or domain terms. However, the difficulty with these techniques is that they do not focus on framework API usage and the code identified will still include many application-specific programming elements that are irrelevant from the viewpoint of framework usage. Several categories of tools have been proposed in lit- erature that focus on API understanding. Code assistants such as XSnippet [6] and FrUiT [7] apply static analysis to the source code of sample applications and allow retrieving code snippets or usage rules for a particular API element in the context of a programming task at hand. They require the developer to know at least some names of the API elements needed for the concept implementation; they are less helpful if the developer has only a high-level idea of the concept to be implemented or if the concept spans multiple classes or both. API comprehension tools like Pattern Extractor [8] and SpotWeb [9] extract API usage patterns from sample applications to provide a general characterization of the whole framework API rather than identifying the relevant concept-implementation steps. Finally, framework evolution comprehension tools such as AURA [10] and SemDiff [11] analyze API changes over the framework evolution to help adapt existing applications to the changes in the new framework API release, but they do not aid implementing concepts from scratch. To help developers implement framework-provided con-