A Pure Embedding of Roles Exploring 4-Dimensional Dispatch for Roles in Structured Contexts
Total Page:16
File Type:pdf, Size:1020Kb
Faculty of Computer Science Institute of Software- and Multimedia-Technology Software Technology Group A PURE EMBEDDING OF ROLES EXPLORING 4-DIMENSIONAL DISPATCH FOR ROLES IN STRUCTURED CONTEXTS Max Leuthäuser Born on: 20th April 1989 in Dresden DISSERTATION to achieve the academic degree DOKTOR-INGENIEUR (DR.-ING.) Referee Prof. Anthony Sloane Supervising professors Prof. Uwe Aßmann Prof. Christel Baier Submitted on: 31st May 2017 Und es liegt darin der Wille, der nicht stirbt. Wer kennt die Geheimnisse des Willens und seine Gewalt? Denn Gott ist nichts als ein großer Wille, der mit der ihm eignen Kraft alle Dinge durchdringt. Der Mensch überliefert sich den Engeln oder dem Nichts einzig durch die Schwäche seines schlaffen Willens. Joseph Glanvill STATEMENT OF AUTHORSHIP I hereby certify that I have authored this Dissertation entitled A Pure Embedding of Roles independently and without undue assistance from third parties. No other than the resources and references indicated in this thesis have been used. I have marked both literal and accordingly adopted quotations as such. There were no additional persons involved in the intellectual preparation of the present thesis. I am aware that violations of this declaration may lead to subsequent withdrawal of the degree. Dresden, 31st May 2017 Max Leuthäuser ABSTRACT Present-day software systems have to fulfill an increasing number of requirements, which makes them more and more complex. Many systems need to anticipate changing contexts or need to adapt to changing business rules or requirements. The challenge of 21th- century software development will be to cope with these aspects. We believe that the role concept offers a simple way to adapt an object-oriented program to its changing context. In a role-based application, an object plays multiple roles during its lifetime. If the contexts are represented as first-class entities, they provide dynamic views to the object- oriented program, and if a context changes, the dynamic views can be switched easily, and the software system adapts automatically. However, the concepts of roles and dynamic contexts have been discussed for a long time in many areas of computer science. So far, their employment in an existing object-oriented language requires a specific runtime environment. Also, classical object-oriented languages and their runtime systems are not able to cope with essential role-specific features, such as true delegation or dynamic binding of roles. In addition to that, contexts and views seem to be important in software development. The traditional code-oriented approach to software engineering becomes less and less satisfactory. The support for multiple views of a software system scales much better to the needs of today’s systems. However, it relies on programming languages to provide roles for the construction of views. As a solution, this thesis presents an implementation pattern for role-playing objects that does not require a specific runtime system, the SCala ROles Language (SCROLL). Via this library approach, roles are embedded in a statically typed base language as dynamically evolving objects. The approach is pure in the sense that there is no need for an additional compiler or tooling. The implementation pattern is demonstrated on the basis of the Scala language. As technical support from Scala, the pattern requires dynamic mixins, compiler-translated function calls, and implicit conversions. The details how roles are implemented are hidden in a Scala library and therefore transparent to SCROLL programmers. The SCROLL library supports roles embedded in structured contexts. Additionally, a four-dimensional, context-aware dispatch at runtime is presented. It overcomes the subtle ambiguities introduced with the rich semantics of role-playing objects. SCROLL is written in Scala, which blends a modern object-oriented with a functional programming language. The size of the library is below 1400 lines of code so that it can be considered to have minimalistic design and to be easy to maintain. Our approach solves several practical problems arising in the area of dynamical extensibility and adaptation. ACKNOWLEDGMENTS We have talked so much about the reader, but you can- not forget that the opening line is important to the writer, too. To the person who is actually boots-on-the- ground. Because it is not just the readers way in, it is the writers way in also, and you have got to find a doorway that fits us both. Stephen King First, I would like to express my special thanks to my supervisor Uwe Aßmann. He supported me and the whole research group with a very special research atmosphere and gave me many useful and path-leading ideas, hints and comments. Additionally, I am very thankful for providing me the opportunity for my stay abroad at the Macquarie University in Sydney. Also, his support allowing me to attend various conferences and workshops was very much appreciated. Special thanks to Sebastian Richly and Sebastian Götz for initially introducing me to the very specific topic of role-based programming. The same goes to Wolfgang Lehner, who does a great job leading the RoSI research training group, and who provided me with many fruitful discussions and comments on my work. Moreover, I like to thank all the past and current colleagues for the relaxing and inter- esting research atmosphere at our chair. Off-topic chats as well as in-depth discussions about ongoing papers or my thesis were always a pleasure. As a member of the RoSI research group special thanks to Thomas, Tobias, Johannes, Steffen, and Stephan for their helpful comments and hints. Furthermore, a special thanks to Anthony Sloane for hosting me at the Macquarie University in Sydney, introducing the city to me, showing me the local highlights and providing interesting discussions about reference attribute grammars and beyond. I am also thankful to my family and friends. My parents always supported me with help, where help was needed. Thank you, Fabian, Uwe, Ronny, Felix, and Martin for all the off-topic chats and fun we had during our student times. A very special thanks goes to my girlfriend Anne, who greatly supported me during my entire PhD project. Even if she has no special interest in computer science, she always encouraged me to keep going. So I did. PUBLICATIONS Sebastian Götz, Max Leuthäuser, Christian Piechnick, Jan Reimann, Sebastian Richly, Julia Schroeter, Claas Wilke, and Uwe Aßmann. Entwicklung Cyber-Physikalischer Systeme am Beispiel des NAO-Roboters. Chemnitzer Linux-Tage - Tagungsband, 2012 Sebastian Götz, Max Leuthäuser, Jan Reimann, Julia Schroeter, Christian Wende, Claas Wilke, and Uwe Aßmann. A Role-Based Language for Collaborative Robot Applica- tions. In Leveraging Applications of Formal Methods, Verification, and Validation, ISoLA SARS, pages 1–15. Springer, 2011 Thomas Kühn, Max Leuthäuser, Sebastian Götz, Christoph Seidl, and Uwe Aßmann. A Metamodel Family for Role-Based Modeling and Programming Languages. In Benoît Combemale, DavidJ. Pearce, Olivier Barais, and JurgenJ. Vinju, editors, Soft- ware Language Engineering, volume 8706 of Lecture Notes in Computer Science, pages 141–160. Springer International Publishing, 2014. ISBN 978-3-319-11244-2. doi: 10.1007/978-3-319-11245-9_8 Max Leuthäuser. SCROLL - A Scala-based library for Roles at Runtime. In van der Storm, Tijs and Erdweg, Sebastian, editor, Proceedings of the 3rd Workshop on Domain-Specific Language Design and Implementation (DSLDI 2015), volume abs/1508.03536, pages 7–8. van der Storm, Tijs and Erdweg, Sebastian, 2015 Max Leuthäuser and Uwe Aßmann. Enabling View-based Programming with SCROLL: Using Roles and Dynamic Dispatch for Establishing View-based Programming. In Proceedings of the 2015 Joint MORSE/VAO Workshop on Model-Driven Robot Soft- ware Engineering and View-based Software-Engineering, MORSE/VAO ’15, pages 25–33, New York, NY, USA, 2015. ACM. ISBN 978-1-4503-3614-7. doi: 10.1145/ 2802059.2802062 Tobias Jäkel, Martin Weißbach, Kai Herrmann, Hannes Voigt, and Max Leuthäuser. Posi- tion Paper: Runtime Model for Role-Based Software Systems. In 2016 IEEE Interna- tional Conference on Autonomic Computing (ICAC), pages 380–387, July 2016. doi: 10.1109/ICAC.2016.17 Max Leuthäuser. Pure Embedding of Evolving Objects. In Proceedings of ADAPTIVE 2017, The Ninth International Conference on Adaptive and Self-Adaptive Systems and Applications, ADAPTIVE 2017. IARIA, 2017 CONTENTS Statement of authorship 5 Abstract 7 Acknowledgments 9 Publications 11 Contents 13 I. Introduction 15 1. Thesis Topic 17 2. Contributions and Outline 19 II. Background and Problem Analysis 21 3. Foundations of Roles 23 3.1. The Historical Term Role ................................ 23 3.2. Issues of Object-oriented Software Design .................... 24 3.3. The Introduction of Roles ............................... 25 3.4. Towards a Common Understanding of Roles ................... 27 3.5. The Compartment Role Object Model (CROM) ................. 30 3.6. The Automaton-based Role-binding Process ................... 33 3.7. Runtime-specific Role Features ........................... 34 4. Foundations of Dispatch 39 4.1. Predicate Dispatch ................................... 41 4.2. Multi-dimensional Dispatch .............................. 41 5. Foundations of Graphs and Graph Filtering 43 6. A Motivating Example for Multi-dimensional Dispatch 47 7. Research Challenges 51 III. Roles in Structured Contexts at Runtime 53 8. The Embedded DSL SCROLL 55 8.1. The Basic Ingredients of the Embedded DSL SCROLL