TL;DR
This paper proposes a novel theory of aspects in software engineering, viewing them as "latent topics" that can be automatically discovered using statistical topic modeling. This approach allows for precise, information-theoretic measurement of "scattering" and "tangling" of concerns, providing a more robust and scalable way to understand and manage crosscutting concerns in software.
What Problem Does This Paper Address?
Aspect-Oriented Programming (AOP) has been around for over a decade, yet its practical value and theoretical underpinnings remain debated. While the concept of aspects (crosscutting concerns) is intuitive, concrete AOP solutions often fall short, leading to a disconnect between the promise and the reality. This discrepancy stems from a lack of a solid, empirically validated theory of aspects. Existing methods for identifying aspects are often manual, small-scale, or rely on assumptions about code structure that might not generalize. The authors aim to bridge this gap by providing a statistically grounded, unsupervised method for identifying and quantifying aspects at scale.
Methods
The core of this paper is the application of Latent Dirichlet Allocation (LDA), a statistical topic modeling technique, to software code. LDA models documents (in this case, source files) as mixtures of latent topics, and topics as mixtures of words. The authors adapt LDA to software by treating source files as documents and carefully selecting tokens (class names, method names, field signatures, etc.) to form the vocabulary.
Crucially, they leverage information theory to quantify "scattering" and "tangling." * Scattering of a concern (topic) is measured by the entropy of its distribution across files. High entropy means the concern is spread widely. * Tangling within a file is measured by the entropy of the file's distribution across topics. High entropy means the file deals with many different concerns.
This approach is "unsupervised," meaning it doesn't require pre-annotated data or specific assumptions about what aspects look like.
Datasets
The primary dataset is a large collection of 4,632 Java projects downloaded from Sourceforge, Tigris, and Apache, comprising approximately 38.7 million lines of code. This dataset was processed and stored in the Sourcerer infrastructure, a system developed by the authors for collecting, parsing, and analyzing software projects.
For smaller-scale validation, the authors also analyzed 5 individual open-source projects: JHotDraw, Jikes, PDFBox, JNode, and CoffeeMud.
Key Insights and Ideas
- Concerns are Latent Topics: The most fundamental idea is that software concerns are not explicitly defined but are "latent topics" that can be discovered through statistical analysis of code.
- Scattering and Tangling as Entropy: Using information theory (entropy) provides a precise, quantitative way to measure how spread out (scattered) a concern is across a codebase and how mixed up (tangled) different concerns are within a single file.
- Unsupervised Discovery: The LDA approach allows for the discovery of aspects without prior knowledge or manual annotation, making it scalable and less prone to human bias.
- General vs. Project-Specific Concerns: The analysis revealed a set of "general-purpose" concerns (like exception handling, logging, concurrency) that appear across many projects, alongside "project-specific" concerns.
- Sigmoidal Tangling Curves: Tangling behavior across projects consistently follows an inverted "S" shape, suggesting a parameterized model for tangling can be developed.
Key Results
- Validation of AOP Hypotheses: The large-scale experiments provided strong evidence that crosscutting concerns, characterized by scattering and tangling, exist to a substantial degree in software projects, validating the first AOP hypothesis.
- Identification of General Concerns: The analysis identified about two dozen high-level, crosscutting concerns that are likely to affect most new Java projects.
- Empirical Measurement: The method successfully identified and quantified scattering and tangling for both the entire repository and individual projects. For instance, in JHotDraw, concerns like "Persistence" and "Undo" showed high scattering entropy, aligning with prior research.
- Parameterized Tangling Model: A simple two-parameter model based on the sigmoid function accurately captured the tangling behavior of software, explaining on average 94.7% of the variation in tangling.
- Comparison with Prior Work: The identified concerns and their scattering/tangling levels showed significant agreement with aspects previously identified through manual analysis, identifier analysis, and other aspect mining techniques, suggesting the LDA approach is both valid and extends previous methods.
Limitations and Future Work
- Vocabulary Selection: While the authors explored various vocabulary selection strategies, the choice of tokens significantly impacts the quality and interpretability of the discovered topics. The optimal strategy might be domain-specific.
- Interpretation of Topics: While LDA is unsupervised, human judgment is still needed to interpret the meaning of the discovered topics and assign meaningful concern names.
- Language Specificity: The current study is focused on Java. While the theory is expected to generalize, further empirical validation on other programming languages and representations (like UML) is needed.
- "Badness" of Scattering/Tangling: The paper acknowledges that the hypothesis that excessive scattering and tangling are "bad" is still an open question, though some evidence suggests this is the case.
- Future Work: The authors suggest integrating this approach into development tools (like IDEs) to track concerns and their scattering/tangling throughout the software development lifecycle. They also propose further research into how this understanding can inform better software design and refactoring.
Summary updated