6 research outputs found

    On the Survival of Android Code Smells in the Wild

    Get PDF
    International audienceThe success of smartphones and app stores have contributed to the explosion of the number of mobile apps proposed to end-users. In this very competitive market, developers are rushed to regularly release new versions of their apps in order to retain users. Under such pressure, app developers may be tempted to adopt bad design or implementation choices, leading to the introduction of code smells. Mobile-specific code smells represent a real concern in mobile software engineering. Many studies have proposed tools to automatically detect their presence and quantify their impact on performance. However, there remains—so far—no evidence about the lifespan of these code smells in the history of mobile apps. In this paper, we present the first large-scale empirical study that investigates the survival of Android code smells. This study covers 8 types of Android code smells, 324 Android apps, 255k commits, and the history of 180k code smell instances. Our study reports that while in terms of time Android code smells can remain in the codebase for years before being removed, it only takes 34 effective commits to remove 75% of them. Also, Android code smells disappear faster in bigger projects with higher releasing trends. Finally, we observed that code smells that are detected and prioritised by linters tend to disappear before other code smells

    Generic Quality-Aware Refactoring and Co-Refactoring in Heterogeneous Model Environments

    Get PDF
    Software has been subject to change, at all times, in order to make parts of it, for instance, more reusable, better to understand by humans, or to increase efficiency under a certain point of view. Restructurings of existing software can be complex. To prevent developers from doing this manually, they got tools at hand being able to apply such restructurings automatically. These automatic changes of existing software to improve quality while preserving its behaviour is called refactoring. Refactoring is well investigated for programming languages and mature tools exist for executing refactorings in integrated development environments (IDEs). In recent years, the development paradigm of Model-Driven Software Development (MDSD) became more and more popular and we experience a shift in the sense that development artefacts are considered as models which conform metamodels. This can be understood as abstraction, which resulted in the trend that a plethora of new so-called model-based Domain-Specific Languages (DSLs) arose. DSLs have become an integral part in the MDSD and it is obvious that models are subject to change, as well. Thus, refactoring support is required for DSLs in order to prevent users from doing it manually. The problem is that the amount of DSLs is huge and refactorings should not be implemented for new for each of them, since they are quite similar from an abstract viewing. Existing approaches abstract from the target language, which is not flexible enough because some assumptions about the languages have to be made and arbitrary DSLs are not supported. Furthermore, the relation between a strategy which finds model deficiencies that should be improved, a resolving refactoring, and the improved quality is only implicit. Focussing on a particular quality and only detecting those deficiencies deteriorating this quality is difficult, and elements of detected deficient structures cannot be referred to in the resolving refactoring. In addition, heterogeneous models in an IDE might be connected physically or logically, thus, they are dependent. Finding such connections is difficult and can hardly be achieved manually. Applying a restructuring in a model implied by a refactoring in a dependent model must also be a refactoring, in order to preserve the meaning. Thus, this kind of dependent refactorings require an appropriate abstraction mechanism, since they must be specified for dependent models of different DSLs. The first contribution, Role-Based Generic Model Refactoring, uses role models to abstract from refactorings instead of the target languages. Thus, participating structures in a refactoring can be specified generically by means of role models. As a consequence, arbitrary model-based DSLs are supported, since this approach does not make any assumptions regarding the target languages. Our second contribution, Role-Based Quality Smells, is a conceptual framework and correlates deficiencies, their deteriorated qualities, and resolving refactorings. Roles are used to abstract from the causing structures of a deficiency, which then are subject to resolving refactorings. The third contribution, Role-Based Co-Refactoring, employs the graph-logic isomorphism to detect dependencies between models. Dependent refactorings, which we call co-refactorings, are specified on the basis of roles for being independent from particular target DSLs. All introduced concepts are implemented in our tool Refactory. An evaluation in different scenarios complements the thesis. It shows that role models emerged as very powerful regarding the reuse of generic refactorings in arbitrary languages. Role models are suited as an interface for certain structures which are to be refactored, scanned for deficiencies, or co-refactored. All of the presented approaches benefit from it.:List of Figures xv List of Tables xvii List of Listings xix 1. Introduction 1 1.1. Language-Tool Generation Without Consideration Of Time And Space . . . . . 4 1.2. Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3. Generic Quality-Aware Refactoring and Co-Refactoring in Heterogeneous Model Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2. Foundations 15 2.1. Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.2. Model-Driven Software Development . . . . . . . . . . . . . . . . . . . . . . . . 16 2.2.1. Levels of Abstraction and Metamodelling . . . . . . . . . . . . . . . . . 17 2.2.2. Model Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.3. Role-Based Modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3. Related Work 23 3.1. Model Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.1.1. Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.1.2. Literature Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.1.3. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.2. Determination of Quality-Related De ciencies . . . . . . . . . . . . . . . . . . . 32 3.2.1. Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.2.2. Literature Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.2.3. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 3.3. Co-Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 3.3.1. Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 3.3.2. Literature Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.3.3. Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3.4. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4. Role-Based Generic Model Refactoring 51 4.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 4.2. Specifying Generic Refactorings with Role Models . . . . . . . . . . . . . . . . . 53 4.2.1. Specifying Structural Constraints using Role Models . . . . . . . . . . . 55 4.2.2. Mapping Roles to Language Concepts Using Role Mappings . . . . . . . 57 4.2.3. Specifying Language-Independent Transformations using Refactoring Speci cations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 4.2.4. Composition of Refactorings . . . . . . . . . . . . . . . . . . . . . . . . . 67 4.3. Preserving Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 4.4. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5. Suggesting Role Mappings as Concrete Refactorings 73 5.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.2. Automatic Derivation of Suggestions for Role Mappings with Graph Querying . 74 5.3. Reduction of the Number of Valid Matches . . . . . . . . . . . . . . . . . . . . . 76 5.4. Comparison to Model Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 5.5. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 6. Role-Based Quality Smells as Refactoring Indicator 79 6.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 6.2. Correlating Model De ciencies, Qualities and Refactorings . . . . . . . . . . . . 80 6.2.1. Quality Smell Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 6.2.2. Quality Smell Calculation Repository . . . . . . . . . . . . . . . . . . . . 85 6.3. Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 6.4. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 7. A Quality Smell Catalogue for Android Applications 89 7.1. Quality Smell Catalogue Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 7.2. Acquiring Quality Smells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 7.3. Structure-Based Quality Smells—A Detailed Example . . . . . . . . . . . . . . . 92 7.3.1. The Pattern Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 7.3.2. Quality Smell: Interruption from Background . . . . . . . . . . . . . . . 93 7.4. Quality Smells for Android Applications . . . . . . . . . . . . . . . . . . . . . . 96 7.4.1. Quality Smell: Data Transmission Without Compression . . . . . . . . . 96 7.4.2. Quality Smell: Dropped Data . . . . . . . . . . . . . . . . . . . . . . . . 98 7.4.3. Quality Smell: Durable WakeLock . . . . . . . . . . . . . . . . . . . . . 98 7.4.4. Quality Smell: Internal Use of Getters/Setters . . . . . . . . . . . . . . . 99 7.4.5. Quality Smell: No Low Memory Resolver . . . . . . . . . . . . . . . . . 101 7.4.6. Quality Smell: Rigid AlarmManager . . . . . . . . . . . . . . . . . . . . 101 7.4.7. Quality Smell: Unclosed Closeable . . . . . . . . . . . . . . . . . . . . . 102 7.4.8. Quality Smell: Untouchable . . . . . . . . . . . . . . . . . . . . . . . . . 103 7.5. Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 8. Role-Based Co-Refactoring in Multi-Language Development Environments 105 8.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 8.2. Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 8.3. Dependency Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 8.3.1. Categories of Model Dependencies . . . . . . . . . . . . . . . . . . . . . 108 8.3.2. When to Determine Model Dependencies . . . . . . . . . . . . . . . . . 110 8.3.3. How to Determine Model Dependencies . . . . . . . . . . . . . . . . . . 111 8.4. Co-Refactoring Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 8.4.1. Specifying Coupled Refactorings with Co-Refactoring Speci cations . . 114 8.4.2. Specifying Bindings for Co-Refactorings . . . . . . . . . . . . . . . . . . 116 8.4.3. Determination of Co-Refactoring Speci cations . . . . . . . . . . . . . . 118 8.5. Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 8.6. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 9. Refactory: An Eclipse Tool For Quality-Aware Refactoring and Co-Refactoring 121 9.1. Refactoring Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 9.1.1. Role Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 9.1.2. Refactoring Speci cation . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 9.1.3. Role Model Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 9.1.4. Refactoring Composition . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 9.1.5. Custom Refactoring Extensions . . . . . . . . . . . . . . . . . . . . . . . 129 9.1.6. Pre- and Post-conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 9.1.7. Integration Into the Eclipse Refactoring Framework . . . . . . . . . . . . 130 9.2. Quality Smell Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 9.3. Co-Refactoring Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 9.3.1. Concrete Syntax of a CoRefSpec . . . . . . . . . . . . . . . . . . . . . . . 138 9.3.2. Expression Evaluation by Using an Expression Language . . . . . . . . . 138 9.3.3. UI and Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 9.4. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 10. Evaluation 143 10.1. Case Study: Reuse of Generic Refactorings in many DSLs . . . . . . . . . . . . . 143 10.1.1. Threats to validity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 10.1.2. Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 10.1.3. Experience Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 10.2. Case Study: Suggestion of Valid Role Mappings . . . . . . . . . . . . . . . . . . 147 10.2.1. Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 10.2.2. Evaluation and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . 151 10.3. Proof of Concept: Co-Refactoring OWL and Ecore Models . . . . . . . . . . . . 155 10.3.1. Coupled OWL-Ecore Refactorings . . . . . . . . . . . . . . . . . . . . . 156 10.3.2. Realisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 10.3.3. Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 11. Summary, Conclusion and Outlook 161 11.1. Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 11.2. Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 11.3. Outlook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Appendix 169 A. List of Role Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 B. Comparison to Role Feature Model . . . . . . . . . . . . . . . . . . . . . . . . . 171 C. Complete List of Role Mappings . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 D. List of all IncPL Patterns for Detecting Quality Smells . . . . . . . . . . . . . . . 176 E. Post-Processor of the Extract CompositeState refactoring for UML State Machines 183 F. Speci cation of the Conference Language . . . . . . . . . . . . . . . . . . . . . . 185 List of Abbreviations 187 Bibliography 19

    Automated Coevolution of Source Code and Software Architecture Models

    Get PDF
    Zur Entwicklung komplexer Softwaresysteme, werden neben dem Quelltext zusätzliche Artefakte, wie beispielsweise Architekturmodelle, verwendet. Wenn die verwendeten Architekturmodelle während der Entwicklung und Evolution eines Softwaresystems konsistent mit dem Quelltext sind, können Softwarearchitekten und Softwareentwickler bei der Entwicklung der Systeme besser unterstützt werden. Architekturmodelle, die auf dem aktuellem Stand sind, vereinfachen Entwicklungs- und Evolutionssaufgaben, da einfacher beantwortet werden kann wie und wo neue Funktionen implementiert werden sollen. Außerdem ist es möglich, modellbasierte Analysen mit Hilfe der Softwarearchitekturmodelle vorzunehmen. Beispielsweise können mit dem Palladio Komponentenmodell (PCM) Performanzvorhersagen durchgeführt werden, wenn ein Architekturmodell des Softwaresystems vorhanden ist und dieses Verhaltensspezifikationen beinhaltet. Wenn Architekturmodelle bei der Softwareentwicklung und Softwareevolution verwendet werden, können die beiden bekannten Probleme Architekturdrift und Architekturverletzung auftreten. Diese Probleme treten für gewöhnlich auf, wenn bei voranschreitender Entwicklung des Quelltextes die Architektur nicht konsistent zu diesem gehalten wird. Dies führt zu veralteten und schlussendlich nutzlosen Architekturmodellen. Viele existierende Ansätze, zur Vermeidung dieser Probleme, zielen darauf ab, Quelltext und UML-Klassendiagramme konsistent zu halten, oder sie zielen darauf ab, Architekturinformationen in den Quelltext einzubetten. In letzterem Fall wird die Notwendigkeit, die Architektur konsistent mit dem Quelltext zu halten, umgangen, da die Architektur integraler Bestandteil des Quelltextes ist. In der vorliegenden Dissertation beschreiben wir einen neuen Ansatz, um komponentenbasierte Architekturmodelle, welche sich auf einer hohen Abstraktionsebene befinden, konsistent mit dem Quelltext zu halten. Wir beschreiben, wie Instanzen des PCMs konsistent mit Java-Quelltext gehalten werden können. Um Konsistenz zu erreichen, werden Architekturelemente erzeugt, gelöscht oder geändert, sobald ihre entsprechende Quelltextelemente geändert wurden, und umgekehrt. Für die Umsetzung der Konsistenzerhaltung stellen wir einen änderungsgetriebenen Ansatz vor. Dieser verwendet benutzerdefinierte, änderungsgetriebene Abbildungsregeln, um die Konsistenz zwischen den beteiligten Modellen sicherzustellen. In dieser Dissertation stellen wir vier konkrete Mengen von Abbildungsregeln zwischen Architekturmodellen und Quelltext vor. Diese haben wir in einer prototypischen Implementierung des Ansatzes umgesetzt. Wir stellen außerdem einen Mechanismus vor, der mit den Benutzern des Konsistenzerhaltungsansatzes interagiert, wenn die Konsistenz nicht automatisch erhalten werden kann, sondern die Benutzer zuerst ihre Intention, die sie mit einer bestimmten Änderung verfolgen, dem Ansatz mitteilen müssen. In diesem Fall müssen die Benutzer das genaue Vorgehen für die Konsistenzerhaltung spezifizieren. Da der vorgestellte Ansatz änderungsgetrieben funktioniert, ist es notwendig, dass wir alle Änderungen in den beteiligten Architektur- und Quelltexteditoren aufzeichnen können. Um es Benutzern zu erlauben, vorhandene Editoren, mit denen sie sich auskennen, wiederverwenden zu können, haben wir Beobachter für diese Editoren implementiert. Diese Beobachter zeichnen alle Änderungen an einem Modell auf und informieren unseren Ansatz über jede durchgeführte Änderung. Der in dieser Dissertation vorgestellte Ansatz erlaubt es auch, verhaltensbeschreibende Architekturmodelle konsistent mit dem Quelltext zu halten. Um dies zu erreichen, haben wir einen Ansatz implementiert, der es ermöglicht, Service Effect Specifications des PCMs inkrementell aus Methoden zu erstellen, nachdem diese geändert wurden. Die Service Effect Specifications werden innerhalb des PCMs genutzt, um das Verhalten einer Komponente zu spezifizieren. Um bereits bestehende Architekturmodelle und bestehenden Quelltext innerhalb unseres Ansatzes verwenden zu können, stellen wir je eine Integrationsstrategie für die Architektur und den Quelltext vor. Um bestehende Architekturmodelle zu integrieren, simulieren wir deren Erstellung. Während dieses Erstellvorgangs zeichnen wir die Änderungen auf, die nötig sind, um das Architekturmodell zu erstellen. Diese Änderungen werden als Eingabe für den Konsistenzerhaltungsprozess verwendet, um daraus den entsprechenden Quelltext zu erzeugen. Um vorhandenen Quelltext einzubinden, stellen wir einen Ansatz vor, der auf Architekturrekonstruktionsverfahren basiert, d.h., zuerst wird die Architektur eines bestehenden Softwaresystems rekonstruiert. Die erstellte Architektur wird anschließend zusammen mit dem bestehenden Quelltext in unseren Coevolutionsansatz integriert. Oftmals ist bestehender Quelltext jedoch nicht so aufgebaut, wie es die Abbildungsregeln vorschreiben. Innerhalb der Integrationsstrategie für Quelltext stellen wir deshalb einen Ansatz vor, der in der Lage ist, solche Quelltexte dennoch zu integrieren. Dieser Ansatz ermöglicht es, nicht nur diese Art von Quelltext zu integrieren, sondern diesen auch mit speziell definierten Abbildungsregeln automatisch konsistent zu halten. Wir haben unseren Ansatz in verschiedenen Fallstudien evaluiert. Dabei haben wir zunächst gezeigt, dass es möglich ist vorhandene Architekturmodelle zu integrieren, indem ihr Aufbau simuliert wird. In der durchgeführten Fallstudie ist es mit unserem Ansatz und den vorgestellten Abbildungsregeln möglich, zwischen 98% und 100% der unterstützten Elemente zu integrieren. Als nächstes haben wir gezeigt, dass unser Ansatz in der Lage ist, existierenden Quelltext zu integrieren und Änderungen am integrierten Quelltext konsistent mit der Architektur zu halten. Für diese Fallstudie haben wir zunächst den Quelltext von vier quelloffenen Projekten in den Ansatz integriert. Als nächstes haben wir gezeigt, dass es möglich ist, Änderungen am Quelltext konsistent mit der Architektur zu halten. Dazu haben wir eine alte Version des Quelltextes integriert und Änderungen die zwischen einer alten und neueren Version durchgeführt wurden, aus einem Versionskontrollsystem extrahiert und erneut auf den Quelltext angewendet. Im Rahmen dieser Evaluation haben wir auch gezeigt, dass es möglich ist Änderungen, die innerhalb von Methoden durchgeführt werden, mit einem Verhaltensmodell konsistent zu halten. Wir haben außerdem eine Evaluation der Leistungsfähigkeit unseres Ansatzes durchgeführt und gezeigt, dass unser Ansatz in den meisten Fällen in der Lage ist, die Architektur in einer Zeit zwischen einer und fünf Sekunden konsistent zu halten, nachdem eine Änderung am Quelltext durchgeführt wurde. Als letztes haben wir gezeigt, dass es möglich ist, coevolvierte Modelle für die Performanzvorhersage zu verwenden. Dazu haben wir zuerst die Modelle in einem Parametrisierungsschritt mit den nötigen Ressourcenverbräuchen angereichert. Als nächstes konnten wir die Performanzvorhersage durchführen. In unserer Fallstudie zeigte sich, dass der Vorhersagefehler für die Antwortzeit eines Systems bei ca. 10% liegt, und damit die coevolvierten Modelle für die Abschätzung der Performanz eines realen Systems verwendet werden können
    corecore