Aspect-Oriented Modelling of Software Framework Interfaces
Total Page:16
File Type:pdf, Size:1020Kb
Aspect-Oriented Modelling of Software Framework Interfaces Emil Dafinov Master of Science School of Computer Science McGill University Montreal,Quebec 2013-08-15 A thesis submitted to McGill University in partial fulfillment of the requirements of the degree of Master of Science Copyright 2013 Emil Dafinov. All rights reserved DEDICATION This work is dedicated to three very important women in my life, all of whom are far more accomplished academics than I could ever hope to be. One is my sister, who embarked on the road to graduate studies, despite her claims that she would never do that. The second is my mother, who stressed the importance of education throughout my whole life. She set a shining example by starting her graduate studies after her eldest daughter had already done so and graduating before her. The last but not least person I would like to mention is the lovely lady who became a part of my life at the time of the writing of this thesis. Something tells me she would have have preferred a citation to a dedication. ii ACKNOWLEDGEMENTS First and foremost, I would like to thank my supervisor, Professor J¨org Kienzle, for his patience, guidance and continuous support throughout my graduate studies. I would also like to thank my colleagues at the McGill University : Wisam Al Abed, Omar Alam and Matthias Sch¨ottlefor putting up with my endless questions about the workings of Reusable Aspect Models (RAM), and everyone at the the Software Engineering Lab in general, for being a great friend and for making my M.Sc. experience so enjoyable. iii ABSTRACT Object-oriented software frameworks are a prominent way of software reuse, since they allow for increased developer productivity. However, frame- works often present the user with a steep learning curve before they can be leveraged efficiently. This issue is caused by the fact that frameworks offer rich feature sets, yet their documentation is often incomplete and informal. In the following thesis we propose a method that relies on feature diagrams in order to describe the features offered by a given framework and the relation- ships between them. The Reusable Aspect Models method is used in order to formally describe the individual features' interfaces. The interfaces' structural and behavioral properties are described using UML class diagrams and UML sequence diagrams, respectively. A complete model of the subset of a given framework's interface that is relevant to a particular client application can be created by composing the models of the framework features used by that application. The individual feature models serve as a basis for generating tu- torials showcasing the framework's capabilities, or even portions of the client application code necessary to interface with the framework. In order to test this method, a case study focusing on the Spring framework was conducted. iv ABREG´ E´ Les frameworks orient´esobjet sont un moyen important de la r´eutilisation de code, car ils permettent d'am´eliorerla productivit´edes d´eveloppeurs. Cepen- dant, les frameworks pr´esentent souvent `al'utilisateur une courbe d'apprentissage abrupte avant qu'ils ne puissent ^etreexploit´eesefficacement. La cause de ce probl`emeest le fait que les frameworks offrent des nombreuses fonctionnalit´es, mais leur documentation est souvent incompl`eteet informelle. Dans la th`ese suivante, nous proposons une m´ethode qui s'appuie sur les feature models afin de d´ecrireles caract´eristiques(oufeatures) offertes par un framework et les relations qu'ils existent entre eux. La m´ethode RAM est utilis´eepour d´ecrire formellement les interfaces des caract´eristiques individuelles. Les propri´et´es structurelles des interfaces sont d´efinies`al'aide des diagrammes de classes tandis que les propri´et´escomportementales des interfaces sont d´efinies`al'aide des diagrammes de s´equence.La m´ethode RAM permette aussi de composer les mod`elesindividuels afin de cr´eerun mod`elede la partie de l'interface du framework qui s'applique l'application cliente. Les mod`elespermettent de g´en´ererdes exemples pour l'utilisation du framework. Afin de tester n^otre m´ethode, une ´etude de cas bas´eesur le framework Spring a ´et´er´ealis´ee. v TABLE OF CONTENTS DEDICATION . ii ACKNOWLEDGEMENTS . iii ABSTRACT . iv ABREG´ E..................................´ v LIST OF TABLES . viii LIST OF FIGURES . ix 1 Introduction . 1 1.1 Motivation . 1 1.2 Thesis Goals . 2 1.3 Thesis Contributions . 3 1.3.1 Novel method of formalizing framework interfaces . 3 1.3.2 Adapting the Reusable Aspect Models methodology to a new problem . 4 1.3.3 Case study: the Spring framework . 4 1.4 Thesis Outline . 4 2 Background . 6 2.1 Software Frameworks . 6 2.2 Reusable Aspect Models . 9 2.2.1 The Structural View . 10 2.2.2 Message Views . 12 2.2.3 Aspect Dependencies and Instantiation . 14 2.2.4 Aspect Weaving . 16 2.3 Feature Models . 22 3 Theoretical Contributions . 25 3.1 Capturing framework features with feature models . 25 3.2 Discovering framework features . 26 3.3 Modelling the interface of individual features . 30 3.4 Deriving feature relationships . 33 3.5 Generating the interface of a combination of features (tuto- rials) . 35 vi 4 The Spring Framework Case Study . 37 4.1 The Spring Framework . 37 4.2 Features Modelled . 38 4.2.1 Feature Model . 38 4.2.2 Individual Features . 39 4.2.3 Combining Spring Features . 58 4.3 Difficulties Encountered . 61 5 Related Work . 64 5.1 Understanding framework APIs . 64 5.2 Aspect-Oriented Modelling . 67 5.3 Software Product Lines . 68 6 Conclusions and Future Work . 70 6.1 Observations . 72 6.2 Limitations of the TouchRAM tool . 73 6.3 Future Work . 74 6.4 Final Remarks . 75 LIST OF REFERENCES . 76 vii LIST OF TABLES Table page 3{1 Some Open Source projects using the Spring framework . 27 viii LIST OF FIGURES Figure page 2{1 The Observer aspect . 11 2{2 The ZeroToMany aspect . 16 2{3 The Observer and ZeroToMany aspects woven together . 17 2{4 The PushObserver aspect . 19 2{5 The PushObserver and Observer aspects woven together . 20 2{6 A sample feature model [13] . 23 3{1 E-Shop Feature Model [4] . 25 3{2 Sample Feature Model including the Observer and PushOb- server features [8] . 34 4{1 Spring Features . 38 4{2 Structural View of the BeanContainer aspect . 40 4{3 Message Views of the BeanContainer aspect . 41 4{4 Structural View of the XmlBeanFactory aspect . 42 4{5 Structural View of the BeanContainerConfigurable aspect . 43 4{6 BeanContainerConfigurable.setupContainer Message View Ref- erence . 44 4{7 BeanContainerConfigurable.readDefinitions Aspect Message View 44 4{8 Structural View of the InitializingBean aspect . 45 4{9 InitializingBean.initialize Aspect Message View . 47 4{10 InitializingBean.getBeanInstance Message View Reference . 47 4{11 Structural View of the BeanPostProcessor aspect . 48 4{12 BeanPostProcessor.setupContainer Message View Reference . 48 4{13 BeanPostProcessor.getBeanInstance Message View Reference . 48 ix 4{14 BeanPostProcessor.addPostProcessor Aspect Message View . 49 4{15 BeanPostProcessor.postProcessBefore Aspect Message View . 50 4{16 BeanPostProcessor.postProcessAfter Aspect Message View . 51 4{17 Structural View of the EventPublisher aspect . 53 4{18 EventPublisher.setupApplicationContext Aspect Message View 54 4{19 EventPublisher.setupContainer Message View Reference . 54 4{20 EventPublisher.publishEvent Aspect Message View . 55 4{21 Structural View of the Transaction aspect . 56 4{22 Transaction.transactionaExecution Aspect Message View . 57 4{23 Woven model for the fBeanContainer, XmlBeanFactoryg fea- ture selection . 59 4{24 Woven model for the fBeanContainer, XmlBeanFactory, Initial- izingBean, BeanPostProcessor, BeanContainerConfigurableg feature selection - Structural View . 60 4{25 Woven model for the fBeanContainer, XmlBeanFactory, Initial- izingBean, BeanPostProcessor, BeanContainerConfigurableg feature selection - Message Views . 63 x Chapter 1 Introduction 1.1 Motivation As the complexity of modern software increases, the need for relying on reusable software modules becomes greater than ever. In order to increase productivity, software developers need to be able to concentrate on develop- ing high-level features that are specific to the products they are working on. Having to spend time implementing lower-level application infrastructure is often tedious and time-consuming. Moreover, a lot of this low-level function- ality could be present in multiple applications. Good software engineering practices suggest that the code implementing this shared functionality should not be re-implemented for every client application. In order to address these issues, developers need to rely on software frameworks. A software framework provides code that can be reused by client applications in order to solve a particular problem. Although this definition sounds very similar to the defi- nition of software libraries, there are several important distinctions that exist between the two. First and foremost, an object-oriented software library con- tains classes and methods that the client code would instantiate and call in order to achieve its (the client's) goals. Frameworks on the other hand are based on the principle of Inversion of Control (IoC): the client is responsible for writing application specific code that is to be called by the framework code at runtime. Thus, it is the framework code and not the user application that defines the control flow of the resulting application. In order to achieve this, the application-specific client code must conform to a rigid API defined by the framework. In short, in the final application the framework provides a 1 backbone, whose functionality can be specialized in order to fit the need of each individual client application. A framework usually aims to provide some default functionality out of the box, but it expects the client code to extend and override it in order to suit its needs.