Aspectmaps: a Scalable Visualization of Join Point Shadows
Total Page:16
File Type:pdf, Size:1020Kb
AspectMaps: A Scalable Visualization of Join Point Shadows Johan Fabry ∗ Andy Kellens y Simon Denier PLEIAD Laboratory Software Languages Lab Stephane´ Ducasse Computer Science Department (DCC) Vrije Universiteit Brussel RMoD, INRIA Lille - Nord Europe University of Chile Belgium France http://pleiad.cl http://soft.vub.ac.be http://rmod.lille.inria.fr of join points. Second, the specification of the implicit invocations is made through a pointcut that selects at which join points the Abstract aspect executes. The behavior specification of the aspect is called the advice. An aspect may contain various pointcuts and advices, When using Aspect-Oriented Programming, it is sometimes diffi- where each advice is associated with one pointcut. cult to determine at which join point an aspect will execute. Simi- The concepts of pointcuts and advices open up new possibil- larly, when considering one join point, knowing which aspects will ities in terms of modularization, allowing for a clean separation execute there and in what order is non-trivial. This makes it difficult between base code and crosscutting concerns. However this sepa- to understand how the application will behave. A number of visu- ration makes it more difficult for a developer to assess system be- alization tools have been proposed that attempt to provide support havior. In particular, the implicit invocation mechanism introduces for such program understanding. However, they neither scale up to an additional layer of complexity in the construction of a system. large code bases nor scale down to understanding what happens at This can make it harder to understand how base system and aspects a single join point. In this paper, we present AspectMaps – a visu- interact and thus how the system will behave. alization that does scale in both directions, thanks to a multi-level Various well-documented issues within the aspect-oriented selective structural zoom. We show how the use of AspectMaps community serve as a testimony to this problem. For example, in- allows for program understanding of code with aspects, revealing herent limitations of the expressiveness of pointcut languages have both a wealth of information of what can happen at one partic- an impact on the ease with which the correct set of join points can ular join point as well as allowing to see the “big picture” on a be captured in a pointcut expression [17]. One well-documented larger code base. We demonstrate the usefulness of AspectMaps on case of this is the so-called fragile pointcut problem [19, 21]. It three small examples and present the results of a user study that states that – upon evolution of the base code of an aspect-oriented shows that AspectMaps clearly outperforms other aspect visualiza- system – seemingly innocent changes to that base code can lead to tion tools. unintended and erroneous behaviour. A similar problem that may Note: This paper heavily uses colors. Please use a color version arise is that in complex systems, multiple aspects can intervene at to better understand the ideas presented here. the same join point. If a developer is not aware of the interactions Keywords aspect-oriented programming, visualization, join point of multiple aspects intervening at the same join point, this again shadow can result in erratic application behavior [24]. Consequently, there is a need for tools that allow software devel- opers to easily assess the impact of aspects on the base system to aid 1. Introduction in the detection and prevention of the problems we discussed above. Aspects modularize cross-cutting concerns by encapsulating not While software visualization is known to be a good approach to only their behavior but also where and how they are invoked. As achieve this, current visualizations fall short on various points, as a result, the other modules of the system, called the base code, we show in this paper. perform implicit invocations to the behavior of the aspects. First, We present a visualization to aid the understanding of aspect- the flow of execution of the base application is reified as a sequence oriented software systems, called AspectMaps. It provides a scal- able visualization of implicit invocation. AspectMaps renders se- ∗ Partially funded by FONDECYT project 1090083. lected join point shadows: locations in the source code that at run- y Funded by a research mandate provided by the “Institute for the Promotion time produce a join point. AspectMaps shows the join point shad- of Innovation through Science and Technology in Flanders” (IWT Vlaan- ows where an aspect is specified to execute, and if multiple as- deren) pects will execute, the order in which they are specified to run. This results in a visualization that clearly shows how aspects cross- cut the base code, as well as how they interact at each join point. AspectMaps is a scalable visualization mainly due to its use of se- lective structural zooming. The structure of source code is shown at different levels of granularity, as determined by the user. As- pectMaps is also implemented as an open source tool, download- able from its website http://pleiad.cl/aspectmaps, which further- more features screencasts of the tool in action. [Copyright notice will appear here once ’preprint’ option is removed.] 1 2011/1/9 The remainder of the paper is structured as follows: we next • Scalability: The visualization should be able to work on small give an overview of software visualization, detailing typical pitfalls data samples, as well as large quantities of data. When applied as well as providing an evaluation of the currently most complete to large amounts of data, the visualization should still be com- aspect visualization. Section 3 introduces the AspectMaps visual- prehensible. One metric that is often applied is that the informa- ization, detailing what is shown at each zoom level. In Section 4 we tion is best represented on one or two screens, thus minimizing show how the use of AspectMaps aids program comprehension, us- the amount of scrolling that is required of the user [5]. ing two examples and an initial user study. We consider future work • Interactivity: A good visualization is not limited to providing in Section 5, followed by an overview of related work in Section 6. a static picture of the system but also provides a means for user Finally, Section 7 concludes. interaction. By adding such functionality to the visualization, the user gets more involved in the process of interpreting the 2. Software Visualization visualization. Additionally, such interactivity might be an ideal Software visualization is defined as the use of graphic means (ty- candidate to improve the scalability of the visualization and to pography, graphic design, animation, . ) to facilitate human un- deal with complexity issues. Interactions can be added to the derstanding and effective use of computer software [26]. The idea visualization (e.g., pop-ups) to convey additional information to of using visualizations to aid in program comprehension is not new. the user, or to limit the scope of the visualization to a particular For example, within the reverse engineering community, software subset of the software system that is visualized [29]. visualizations are a well-established means of supporting various 2.2 Assessing Existing Aspect Visualizations software comprehension tasks [22, 27, 28]. One of the major advantages of software visualizations is Our work is not the first to study the subject of aspect visualization. that they are able to convey a large quantity of information to a In this section we discuss what is arguably the currently most com- user [32]. The human brain can easily combine complex informa- plete visualization: the visualization of the AspectJ Development tion from visual cues, making them a suitable means for under- Toolkit. We provide a brief evaluation of how this visualization per- standing complex software systems. Furthermore, a well-chosen forms with respect to the principles we previously treated. To the visualization allows users to pre-attentively process the informa- best of our knowledge, this is the first time that such an evaluation tion: rather than having to search for specific information (e.g., by has been performed, and we perform it here to provide context for extracting it from the source code), visualizations can immediately the remainder of this paper. draw a user’s attention to specific parts of the system. AspectJ Development Toolkit The AspectJ Development Toolkit 2.1 Visualization Pitfalls (AJDT) for Eclipse [7, 9] is arguably the most mature toolkit for Aspect-Oriented Programming. Amongst other features, AJDT Despite the advantages of software visualizations, designing a good adds gutter markers in the code editor to indicate join point shad- visualization is not a trivial task. A visualization must be suffi- ows for affected code entities, and also provides a textual “Cross- ciently rich such that it can convey the correct information in a References View”. While these features provide useful feedback, single glance. However the user should not be overwhelmed by the they do not scale to a large code base [23]. The gutter markers only visualization, making the extraction of any meaningful information show one extremely fine-grained view. When looking at the source impossible. In cognitive sciences, the topic of data visualization code of one specific class, the developer can see where aspects ap- has been well studied [5, 31], which has produced different guide- ply in the code currently being displayed, and only there. To look lines to follow to design a successful visualization. In what follows, at large classes requires multiple scrolling operations, to view mul- we discuss a number of common pitfalls of software visualizations tiple classes requires opening their code in the editor one by one. and distill from this a set of requirements for our visualization of The cross-references view is, in essence, a textual representation.