A Modeling Framework for Strategic Domain-Driven Design and Service Decomposition
Total Page:16
File Type:pdf, Size:1020Kb
UNIVERSITY OF APPLIED SCIENCES OF EASTERN SWITZERLAND (HSR FHO) MASTER THESIS A Modeling Framework for Strategic Domain-driven Design and Service Decomposition Author: Supervisor: Stefan KAPFERER Prof. Dr. Olaf ZIMMERMANN External Examiner: Dr. Gerald REIF A thesis submitted in fulfillment of the requirements for the degree of Master of Science FHO in Engineering focusing on Information and Communication Technologies in the Software and Systems Master Research Unit January 24, 2020 iii Declaration of Authorship I, Stefan KAPFERER, declare that this thesis titled, “A Modeling Framework for Strategic Domain-driven Design and Service Decomposition” and the work presented in it are my own. I confirm that: • This work was done wholly or mainly while in candidature for a research degree at this University. • Where any part of this thesis has previously been submitted for a degree or any other qualification at this University or any other institution, this has been clearly stated. • Where I have consulted the published work of others, this is always clearly attributed. • Where I have quoted from the work of others, the source is always given. With the exception of such quotations, this thesis is entirely my own work. • I have acknowledged all main sources of help. • Where the thesis is based on work done by myself jointly with others, I have made clear exactly what was done by others and what I have con- tributed myself. Rapperswil, January 24, 2020 Stefan Kapferer v UNIVERSITY OF APPLIED SCIENCES OF EASTERN SWITZERLAND (HSR FHO) Abstract Master of Science FHO in Engineering A Modeling Framework for Strategic Domain-driven Design and Service Decomposition by Stefan KAPFERER The decomposition of a system into modules or services is a challenging prac- tical problem and research question that has not been answered satisfactorily yet. With the current trend towards microservices, Strategic Domain-driven Design (DDD) has become a popular technique to decompose a domain into so-called Bounded Contexts. In our previous work we presented Context Map- per, an open source tool offering a Domain-specific Language (DSL) based on the DDD patterns. It supports the evolution of DDD pattern-based architecture models in a formal and expressive way. By applying Architectural Refactorings (ARs), systems can be decomposed in an iterative manner. However, our vali- dation activities have shown that our tool-based approach requires additional capabilities to expand the target user group. For instance, support for reverse engineering has been requested since re-modeling existing systems is often too expensive in brownfield projects. Decomposition on the basis of a systematic approach and generating graphical Context Maps are other user requirements. With this thesis we propose a modular and extensible component architec- ture for a modeling framework based on Strategic DDD. The already existing Context Mapper tool evolved into a framework offering components for re- verse engineering, architecture modeling, refactoring, systematic decomposi- tion, and generation of other representations from the Context Mapper DSL (CML) models. The DSL constitutes the core component of the framework. With our discovery library we propose a strategy-based approach to reverse engineer CML models. An extended set of ARs has been conceptualized allow- ing users to evolve the architecture models iteratively. With Service Cutter, we integrated a systematic service decomposition approach to derive new Context Maps that improve coupling and cohesion. A graphical Context Map generator enhances the transformation tools to convert CML code into visual diagrams. The proposed framework supports architects and business analysts in cre- ating DDD-based models and improve their productivity at the same time. We hypothesize that the mentioned personas can benefit from a tool which assists them in evolving Context Maps. During this thesis we applied action research to validate our concepts and improve the prototype iteratively. With case studies such as the Lakeside Mutual microservice project and our own framework architecture we validated the usefulness and effectiveness of the suggested modeling framework. The conducted validation activities indicate that the hypothesis above holds true. vii Acknowledgements I would like to express my deep gratitude to my supervisor Prof. Dr. Olaf Zimmermann for his outstanding support during this thesis and throughout my Master’s. I highly appreciate his guidance, insight, and expertise which as- sisted my research projects greatly. By adopting and validating Context Map- per, using and presenting the tool in application architecture courses at HSR, and co-authoring a conference paper, he supported and challenged me during my studies beyond his supervision duties. It has been a great privilege to work and study under his guidance. I am grateful to everyone who gave me the opportunity to present my project in meetups, especially Vaughn Vernon for the possibility to demonstrate Context Mapper in one of his IDDD workshops. I am also thankful to the stu- dents and all those who used the tool and/or provided their valuable feedback that allowed us to validate the research concepts and improve the prototypic implementation of our modeling framework. Last but not least I would like to thank my family and loved ones for being there for me and for supporting me in everything I do in my life. Many thanks to Brigita Okello for proofreading this thesis and all her love and support. I am extremely grateful to my mother and stepfather for their support and advice throughout my life, and for preparing me for my future. The completion of my Master’s and this thesis would not have been possible without them. ix Contents Declaration of Authorship iii Abstractv Acknowledgements vii 1 Introduction1 1.1 Context and Problem..........................1 1.2 Vision...................................2 1.3 Thesis Results..............................3 2 Framework Users and Requirements7 2.1 User Roles and Personas........................7 2.2 Reverse Engineering Scenarios.................... 10 2.3 Structured Service Decomposition.................. 10 2.4 Context Map Evolution with Architectural Refactorings (ARs).. 11 2.5 Generating other Representations................... 11 2.6 Non-Functional Requirements (NFRs)................ 12 3 Analysis of the Modeling Framework Components 17 3.1 Context Map and Bounded Context Discovery Strategies..... 18 3.2 Structured Service Decomposition Algorithms........... 23 3.3 Architectural Refactoring (AR) Selection............... 25 3.4 Graphical DDD Context Map Tool Evaluation............ 33 4 Context Mapper: Design and Implementation 37 4.1 Component Overview......................... 37 4.2 Core: Context Mapping DSL (CML)................. 38 4.3 Discovery Library for Reverse Engineering............. 44 4.4 Service Decomposition with Service Cutter............. 57 4.5 Architectural Refactorings (ARs)................... 64 4.6 Generators................................ 70 4.7 Context Mapper DSL (CML) Example Models........... 78 5 Evaluation and Discussion 81 5.1 Validation via Prototyping, Action Research and Case Studies.. 81 5.2 Requirement Fulfillment Evaluation................. 84 5.3 Strengths and Weaknesses....................... 92 x 6 Comparison with Related Work 97 6.1 Modeling Language........................... 97 6.2 Discovery Library for Reverse Engineering............. 97 6.3 Architectural Refactorings (ARs)................... 98 6.4 Systematic Service Decomposition.................. 99 6.5 Architecture Diagram Generation................... 100 6.6 Microservice Contract and Code Generation............ 100 7 Conclusion and Outlook 103 7.1 Thesis Summary and Results..................... 103 7.2 Future Work............................... 104 A Revised CML Language Reference 109 A.1 Language Design............................ 109 A.2 Terminals................................. 109 A.3 Root Rule................................. 110 A.4 Context Map............................... 110 A.5 Bounded Context............................ 116 A.6 Domain and Subdomains....................... 118 A.7 Use Cases................................ 120 A.8 Domain Vision Statement....................... 121 A.9 Partnership................................ 121 A.10 Shared Kernel.............................. 123 A.11 Customer-Supplier........................... 125 A.12 Conformist................................ 129 A.13 Open Host Service........................... 130 A.14 Anticorruption Layer.......................... 130 A.15 Published Language.......................... 131 A.16 Responsibility Layers.......................... 131 A.17 Knowledge Level............................ 133 A.18 Aggregate................................ 134 A.19 Complete CML Grammar....................... 136 B Architectural Refactoring (AR) Catalog 137 B.1 Structural Refactorings......................... 137 B.2 Relationship Refactorings....................... 145 List of Figures 147 List of Tables 149 List of Abbreviations 151 Bibliography 153 1 Chapter 1 Introduction 1.1 Context and Problem Decomposing a system into appropriately sized services is a challenging task which has gained much attention due to the trend towards (micro-)service- oriented architectures during the last years. Strategic Domain-driven Design (DDD) is a popular approach among practitioners to tackle this challenge. DDD adopters decompose a system by identifying so-called Bounded Contexts1. Con- text Map1