Luận án Phương pháp tiếp cận khung nhìn hợp nhất cho tự động hóa phát triển phần mềm

Vietnam National University, Hanoi VNU University of Engineering and Technology LE MINH DUC A Unified View Approach to Software Development Automation Doctor of Philosophy Dissertation in Information Technology Hanoi - 2020 ĐẠI HỌC QUỐC GIA HÀ NỘI TRƯỜNG ĐẠI HỌC CÔNG NGHỆ LÊ MINH ĐỨC PHƯƠNG PHÁP TIẾP CẬN KHUNG NHÌN HỢP NHẤT CHO TỰ ĐỘNG HÓA PHÁT TRIỂN PHẦN MỀM LUẬN ÁN TIẾN SĨ NGÀNH CÔNG NGHỆ THÔNG TIN Hà Nội - 2020 Vietnam National University, Hanoi VN

pdf193 trang | Chia sẻ: huong20 | Ngày: 07/01/2022 | Lượt xem: 316 | Lượt tải: 0download
Tóm tắt tài liệu Luận án Phương pháp tiếp cận khung nhìn hợp nhất cho tự động hóa phát triển phần mềm, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
NU University of Engineering and Technology LE MINH DUC A Unified View Approach to Software Development Automation Specialisation: Software Engineering Code: 9480103.01 Doctor of Philosophy Dissertation in Information Technology Supervisors: 1. Assoc. Prof., Dr. Nguyen Viet Ha 2. Dr. Dang Duc Hanh Hanoi – 2020 ĐẠI HỌC QUỐC GIA HÀ NỘI TRƯỜNG ĐẠI HỌC CÔNG NGHỆ LÊ MINH ĐỨC PHƯƠNG PHÁP TIẾP CẬN KHUNG NHÌN HỢP NHẤT CHO TỰ ĐỘNG HÓA PHÁT TRIỂN PHẦN MỀM Chuyên ngành: Kỹ thuật Phần mềm Mã số: 9480103.01 LUẬN ÁN TIẾN SĨ NGÀNH CÔNG NGHỆ THÔNG TIN NGƯỜI HƯỚNG DẪN KHOA HỌC: 1. PGS. TS. Nguyễn Việt Hà 2. TS. Đặng Đức Hạnh Hà Nội – 2020 Declaration I hereby declare that the materials presented in this dissertation are my own work, conducted under the supervision of Assoc. Prof., Dr. Nguyen Viet Ha and Dr. Dang Duc Hanh, at the Faculty of Information Technology, University of Engineering and Technology, Vietnam National University, Hanoi. All the research data and results presented in this dissertation are authentic and (to the best of my knowledge) have not previously been published in any academic publications by other authors. Le Minh Duc Abstract An important software engineering methodology that has emerged over the past twenty years is model-based software development. At the heart of this methodology lies two complementary methods: model-driven software engineering (MDSE) and domain-driven design (DDD). While the aim of MDSE is ambitiously broad, DDD’s goal is more modest and direct but not less important – to apply model-based engineering techniques to tackle the complexity inherent in the domain requirements. The state-of-the-art DDD method includes a set of principles for constructing a domain model that is feasible for implementation in a target programming language. However, this method lacks the solutions needed to address the following important design questions facing a technical team when applying DDD in object oriented programming language (OOPL) platforms: (i) what constitues an essentially expressive domain model and (ii) how to effectively construct a software from this model. The dissertation aims to address these limitations by using annotation-based domain-specific language (aDSL), which is internal to OOPL, to not only express an essential and unified domain model but generatively construct modular software from this model. First, we propose an aDSL, named domain class specification language (DCSL), which consists in a set of annotations that express the essential structural constraints and the essential behaviour of a domain class. We carefully select the design features from a number of authoritative software and system engineering resources and reason that they form a minimum design space of the domain class. Second, we propose a unified domain (UD) modelling approach, which uses DCSL to express both the structural and behavioural modelling elements. We choose UML activity diagram language for behavioural modelling and discuss how the domain-specific constructs of this language are expressed in DCSL. To demonstrate the applicability of the approach we define the UD modelling patterns for tackling the design problems posed by five core UML activity flows. Third, we propose a 4-property characterisation for the software that are constructed directly from the domain model. These properties are defined based on a conceptual layered software model that includes the domain model at the core, an intermediate module layer surrounding this core and an outer software layer. Fourth, we propose a second aDSL, named module configuration class language (MCCL), that is used for designing module configuration classes (MCCs) in a module-based software architecture. An MCC provides an explicit class-based definition of a set of module con- figurations of a given class of software modules. The MCCs can easily be reused to create different variants of the same module class, without having to change the module class design. Fifth, we develop a set of software tools for DCSL, MCCL and the generators associated with these aDSLs. We implement these tools as components in a software framework, named jDomainApp, which we have developed in our research. To evaluate the contributions, we first demonstrate the practicality of our method by applying it to a relatively complex, real-world software construction case study, concerning organisational process management. We then evaluate DCSL as a design specification lan- guage and evaluate the effectiveness of using MCCL in module-based software construction. We focus the latter evaluation on module generativity. We contend that our contributions help make the DDD method more concrete and more complete for software development. On the one hand, the method becomes more concrete with solutions that help effectively apply the method in OOPL platforms. On the other hand, the method is more complete with solutions for the design aspects that were not originally included. Tóm tắt Trong vòng hai thập kỷ gần đây, phương pháp luận phát triển phần mềm dựa trên mô hình nổi lên là một phương pháp luận quan trọng trong kỹ nghệ phần mềm. Ở trung tâm của phương pháp luận này có hai phương pháp có tính bổ trợ nhau là: kỹ nghệ phần mềm hướng mô hình (model-driven software engineering (MDSE)) và thiết kế hướng miền (domain-driven design (DDD)). Trong khi MDSE mang một mục tiêu rộng và khá tham vọng thì mục tiêu của DDD lại khiêm tốn và thực tế hơn, đó là tập trung vào cách áp dụng các kỹ thuật của kỹ nghệ dựa trên mô hình để giải quyết sự phức tạp vốn có trong yêu cầu miền. Phương pháp DDD hiện tại bao gồm một tập các nguyên lý để xây dựng một mô hình miền ở dạng khả thi cho triển khai viết mã trên một ngôn ngữ lập trình đích. Tuy nhiên phương pháp này còn thiếu các giải pháp cần thiết giúp giải đáp hai câu hỏi quan trọng mà người phát triển phần mềm thường gặp phải khi áp dụng DDD vào các nền tảng ngôn ngữ lập trình hướng đối tượng (object oriented programming language (OOPL)): (i) những thành phần nào cấu tạo nên một mô hình miền có mức độ diễn đạt thiết yếu? và (ii) xây dựng một cách hiệu quả phần mềm từ mô hình miền như thế nào? Luận án này đặt mục đích khắc phục hạn chế trên của DDD bằng cách sử dụng ngôn ngữ chuyên biệt miền dựa trên ghi chú (annotation-based domain-specific language (aDSL)), được phát triển trong OOPL, để không chỉ biểu diễn một mô hình miền hợp nhất thiết yếu mà còn để xây dựng phần mềm có tính mô-đun từ mô hình miền này. Thứ nhất, luận án đề xuất một aDSL, tên là ngôn ngữ đặc tả lớp miền (domain class specification language (DCSL)), bao gồm một tập các ghi chú để biểu diễn các ràng buộc cấu trúc thiết yếu và các hành vi thiết yếu của lớp miền. Tác giả đã cẩn thận lựa chọn các đặc trưng thiết kế từ một số nguồn tài liệu học thuật có uy tín về kỹ nghệ phần mềm và kỹ nghệ hệ thống và lập luận rằng các đặc trưng này tạo thành một không gian thiết kế tối giản cho lớp miền. Thứ hai, luận án đề xuất một phương thức tiếp cận mô hình hóa miền hợp nhất, trong đó sử dụng DCSL để biểu diễn các thành phần mô hình hóa cấu trúc và hành vi. Luận án đã chọn ngôn ngữ biểu đồ hoạt động UML cho mô hình hóa hành vi và trình bày cách biểu diễn các đặc trưng chuyên biệt trạng thái của ngôn ngữ này bằng DCSL. Để chứng tỏ tính thực tiễn của cách tiếp cận, luận án định nghĩa một tập mẫu mô hình hóa miền hợp nhất cho các bài toán thiết kế liên quan trực tiếp đến năm luồng hoạt động UML cơ bản. Thứ ba, luận án đề xuất một mô tả đặc điểm gồm bốn tính chất cho phần mềm được xây dựng trực tiếp từ mô hình miền. Bốn tính chất này được định nghĩa dựa trên mô hình khái niệm phần mềm dạng phân lớp, bao gồm mô hình miền ở lớp lõi, một lớp mô-đun trực tiếp bao quanh lớp lõi và một lớp phần mềm ở ngoài. Thứ tư, luận án đề xuất một aDSL thứ hai, tên là ngôn ngữ lớp cấu hình mô-đun (module configuration class language (MCCL)), dùng để thiết kế các lớp cấu hình mô-đun (module configuration classes (MCCs)) trong một kiến trúc phần mềm dựa trên mô-đun. Mỗi MCC cung cấp một định nghĩa dạng lớp cho một tập các cấu hình mô-đun của một lớp mô-đun. Các MCC có thể dễ dàng sử dụng lại để tạo ra các biến thể của một lớp mô-đun mà không cần sửa thiết kế bên trong của mô-đun. Thứ năm, luận án phát triển một bộ công cụ dành cho DCSL, MCCL và các bộ sinh mã của các ngôn ngữ này, dưới dạng các thành phần của một phần mềm khung, tên là JDOMAINAPP. Để đánh giá các kết quả trên, luận án trước hết trình diễn tính thực tiễn của phương pháp bằng cách áp dụng vào một trường hợp nghiên cứu tương đối phức tạp về phát triển phần mềm, liên quan đến quản lý quy trình tổ chức. Tiếp theo, luận án đánh giá DCSL từ khía cạnh một ngôn ngữ đặc tả và đánh giá hiệu quả việc sử dụng MCCL trong xây dựng mô-đun phần mềm một cách tự động. Chúng tôi cho rằng, các đóng góp của luận án giúp phương pháp DDD trở nên cụ thể và đầy đủ hơn. Một mặt, phương pháp trở nên cụ thể hơn với các giải pháp giúp áp dụng một cách hiệu quả vào các nền tảng OOPL. Mặt khác, phương pháp trở nên đầy đủ hơn với các giải pháp cho các khía cạnh thiết kế chưa được xem xét tới. Acknowledgement I would first like to thank my supervisors, Assoc. Prof. Nguyen Viet Ha and Dr. Dang Duc Hanh, for their instructions and guidance throughout my research and the development of this dissertation. I would also like to thank all the teachers at the Faculty of Information Technology (University of Engineering and Technology, Hanoi) for the very kind support that I have received throughout my research study at the department. I am deeply grateful for my home university (Hanoi University) for providing the PhD studentship and a gracious teaching arrangement, that has enabled me to have the time to complete the required course works and research. I am also very grateful for the financial support that I have additionally received from the MOET’s 911 fund and the NAFOSTED project (grant number 102.03-2015.25), led by Assoc. Prof. Nguyen Viet Ha. I would also like to thank all of my colleagues and fellow PhD students for the many meaningful and entertaining discussions. Last but not least, I wish to thank my family for the sacrifices that they have made and for all the love and encouragement that they have given me during my PhD study. Contents Glossaryv List of Figures vii List of Tables ix 1 Introduction1 1.1 Problem Statement..............................3 1.1.1 Motivating Example.........................3 1.1.2 Domain-Driven Design Challenges.................5 1.1.3 Research Statement..........................7 1.2 Research Aim and Objectives.........................7 1.3 Research Approach..............................8 1.4 Dissertation Structure............................. 12 2 State of the Art 13 2.1 Background.................................. 13 2.1.1 Model-Driven Software Engineering................. 13 2.1.2 Domain-Specific Language...................... 15 2.1.3 Meta-Modelling with UML/OCL.................. 17 2.1.4 Domain-Driven Design........................ 22 2.1.5 Model-View-Controller Architecture................. 27 2.1.6 Comparing and Integrating MDSE with DDD............ 28 2.1.7 A Core Meta-Model of Object-Oriented Programming Language.. 29 2.1.8 Using Annotation in MBSD..................... 33 i 2.2 Domain-Driven Software Development with aDSL............. 35 2.2.1 DDD with aDSL........................... 36 2.2.2 Behavioural Modelling with UML Activity Diagram........ 36 2.2.3 Software Module Design....................... 40 2.2.4 Module-Based Software Architecture................ 41 2.3 Summary................................... 45 3 Unified Domain Modelling with aDSL 46 3.1 Introduction.................................. 46 3.2 DCSL Domain................................ 47 3.2.1 Essential State Space Constraints.................. 47 3.2.2 Essential Behaviour Types...................... 48 3.3 DCSL Syntax................................. 49 3.3.1 Expressing the Pre- and Post-conditions of Method......... 56 3.3.2 Domain Terms............................ 57 3.4 Static Semantics of DCSL .......................... 57 3.4.1 State Space Semantics........................ 58 3.4.2 Behaviour Space Semantics..................... 64 3.4.3 Behaviour Generation for DCSL Model............... 68 3.5 Dynamic Semantics of DCSL ........................ 71 3.6 Unified Domain Model............................ 72 3.6.1 Expressing UDM in DCSL ...................... 73 3.6.2 UD Modelling Patterns........................ 76 3.7 Summary................................... 87 4 Module-Based Software Construction with aDSL 88 4.1 Introduction.................................. 88 4.2 Software Characterisation........................... 89 4.2.1 An Abstract Software Model..................... 90 4.2.2 Instance-based GUI.......................... 91 4.2.3 Model reflectivity........................... 92 4.2.4 Modularity.............................. 92 4.2.5 Generativity.............................. 94 ii 4.3 Module Configuration Domain........................ 95 4.3.1 One Master Module Configuration.................. 95 4.3.2 The ‘Configured’ Containment Tree................. 95 4.3.3 Customising Descendant Module Configuration........... 96 4.4 MCCL Language Specification........................ 97 4.4.1 Specification Approach........................ 97 4.4.2 Conceptual Model.......................... 98 4.4.3 Abstract Syntax............................ 104 4.4.4 Concrete Syntax........................... 110 4.4.5 Semantics............................... 114 4.5 MCC Generation............................... 114 4.5.1 Structural Consistency between MCC and Domain Class...... 114 4.5.2 MCCGEN Algorithm......................... 116 4.6 Summary................................... 118 5 Evaluation 119 5.1 Implementation................................ 119 5.1.1 UD Modelling............................ 119 5.1.2 Module-Based Software Construction................ 121 5.2 Case Study: ProcessMan .......................... 122 5.2.1 Method................................ 122 5.2.2 Case and Subject Selection...................... 122 5.2.3 Data Collection and Analysis..................... 123 5.2.4 Results................................ 123 5.3 DCSL Evaluation............................... 127 5.3.1 Evaluation Approach......................... 127 5.3.2 Expressiveness............................ 129 5.3.3 Required Coding Level........................ 132 5.3.4 Behaviour Generation........................ 133 5.3.5 Performance Analysis........................ 134 5.3.6 Discussion.............................. 134 5.4 Evaluation of Module-Based Software Construction............. 135 5.4.1 Module Generativity Framework................... 135 iii 5.4.2 MP1: Total Generativity....................... 137 5.4.3 MP2–MP4 .............................. 138 5.4.4 Analysis of MCCGen ........................ 143 5.4.5 Discussion.............................. 144 5.5 Summary................................... 144 6 Conclusion 145 6.1 Key Contributions............................... 146 6.2 Future Work.................................. 147 Bibliography 150 Appendices A Helper OCL Functions for DCSL’s ASM 158 B MCCL Specification 164 B.1 Library Rules of the MCCL’s ASM..................... 164 B.2 Two MCCs of ModuleEnrolmentMgmt .................... 167 C DCSL Evaluation Data 171 C.1 Expressiveness Comparison Between DCSL and the DDD Frameworks.. 171 C.2 Level of Coding Comparison Between DCSL and the DDD Frameworks.. 173 iv Glossary aDSL Annotation-Based DSL, page 36 ASM Abstract Syntax Meta-model, page 17 AtOP Attribute-Oriented Programming, page 35 BISL Behaviour Interface Specification Language, page 35 CSM Concrete Syntax Meta-model, page 17 DCSL Domain Class Specification Language, page 51 DDD Domain-Driven Design, page 22 DDDAL DDD with aDSLs, page 8 DSL Domain-Specific Language, page 15 JML Java Modelling Language, page 36 MCC Module Configuration Class, page 99 MCCL Module Configuration Class Language, page 99 MDA Model-Driven Architecture, page 13 MDD Model-Driven Development, page 13 MDE Model-Driven Engineering, page 13 MDSE Model-Driven Software Engineering, page 13 v MVC Model-View-Controller, page 27 OCL Object Constraint Language, page 18 OOPL Object-Oriented Programming Language, page 29 PIM Platform-Independent Model, page 14 PSM Platform-Specific Model, page 14 SDM Semantic Domain Meta-model, page 17 UDM Unified Domain Model, page 76 UML Unifield Modelling Language, page 18 UML/OCL UML made precise with OCL, page 18 vi List of Figures 1.1 A partial domain model of CourseMan....................3 1.2 An overview of DDDAL (with an emphasis on phases 1 and 2)........9 2.1 The essential ASM of UML (synthesised from seven meta-models of UML [57]). 18 2.2 The OCL expression meta-model (Adapted from §8.3 [56])......... 20 2.3 A UI class of the domain class Student (Source: [45])............ 28 2.4 The UML-based ASM of OOPL........................ 30 2.5 The meta-model of UML activity modelling language (Adapted from §15.2.2 of the UML specification [57])......................... 38 2.6 The UML activity models of five basic variants of the CourseMan’s enrol- ment management activity........................... 39 2.7 The MOSA model of CourseMan...................... 43 2.8 A ModuleEnrolmentMgmt’s view containing a child ModuleStudent’s view. 44 3.1 The abstract syntax model of DCSL...................... 50 3.2 A DCSL model for a part of the CourseMan domain model......... 55 3.3 (A: Left) The UML activity and class models of a CourseMan software variant that handles the enrolment management activity; (B: Right) The UDM that results................................ 75 3.4 The sequential pattern form (top left) and an application to the enrolment management activity.............................. 77 3.5 The sequential pattern form view of enrolment management activity..... 78 3.6 The decisional pattern form (top left) and an application to the enrolment management activity.............................. 79 3.7 The decisional pattern form view of enrolment management activity..... 80 vii 3.8 The forked pattern form (top left) and an application to the enrolment man- agement activity................................ 81 3.9 The forked pattern form view of enrolment management activity....... 82 3.10 The joined pattern form (top left) and an application to the enrolment man- agement activity................................ 83 3.11 The joined pattern form view of enrolment management activity....... 84 3.12 The merged pattern form (top left) and an application to the enrolment man- agement activity................................ 85 3.13 The merged pattern form view of enrolment management activity...... 86 4.1 A detailed view of DDDAL’s phase 2 with software module construction.. 89 4.2 An abstract UML-based software model: (core layer) domain model, (middle layer) module and (top layer) software..................... 90 4.3 The GUI of CourseMan software prototype generated by jDomainApp: (1) main window, (2-4) the UDM’s GUI for EnrolmentMgmt, Student, and Enrolment.................................. 91 4.4 The CM of MCCL............................... 98 4.5 (A-shaded area) The transformed CM (CMT ); (B-remainder) Detailed design of the105 key classes of CMT . 4.6 The annotation-based ASM.......................... 109 4.7 The view of a (stand-alone) ModuleStudent object.............. 111 4.8 The customised view of ModuleEnrolmentMgmt (as configured in Listing 4.2).113 5.1 A partial CourseMan’s GUI that is generated by DomainAppTool..... 121 5.2 ProcessMan’s domain model......................... 124 5.3 A partial MCC Model for process structure.................. 125 5.4 The view of ModuleEnrolmentMgmt of the software in Figure 5.1...... 138 5.5 An example CourseMan software that has substantially been customised.. 141 A.1 Utility class ExprTk.............................. 158 A.2 Utility class Tk................................. 160 viii List of Tables 2.1 Meta-mapping between OOPL and UML/OCL............... 33 3.1 The essential state space constraints..................... 48 3.2 The essential behaviour types......................... 49 3.3 Well-formedness constraints of DCSL .................... 59 3.4 The boolean state space constraints of DCSL ................ 60 3.5 The non-boolean state space constraints of DCSL .............. 63 3.6 The core structural mapping rules...................... 67 3.7 Translating Domain Field properties into JML’s class invariants....... 72 4.1 Mapping from CM to CMT .......................... 107 5.1 The expressiveness aspects and domain properties of interest........ 128 5.2 (A-left) Comparing DCSL to DDD patterns; (B-right) Comparing DCSL to AL and XL.................................. 130 5.3 (A-left) Summary of max-locs for DCSL, AL and XL; (B-right) Summary of typical-locs for DCSL, AL and XL.................... 132 5.4 BSpaceGen for CourseMan ......................... 133 5.5 Module pattern classification......................... 135 5.6 Module generativity values of two CourseMan’s modules in MP2–MP4 . 140 C.1 Comparing the expressiveness of DCSL to AL, XL............. 171 C.2 Comparing the max-locs of DCSL to AL, XL................ 173 C.3 Comparing the typical-locs of DCSL to AL, XL............... 174 ix Chapter 1 Introduction There is no doubt that an important software engineering research area over the last two decades is what we would generally call model-based software development (MBSD) – the idea that a software can and should systematically be developed from abtractions, a.k.a models, of the problem domain. MBSD brings many important benefits, including ease of problem solving and improved quality, productivity and reusability. Perhaps a most visible and novel software engineering development that falls under the MBSD umbrella is model-driven software engineering (MDSE) [9, 16, 38, 67]. Another more modest and direct development method is domain-driven design (DDD) [22, 62, 75]. Very early on, Czarnecki [16] stated that MDSE is a type of generative software devel- opment (GSD). The key benefits of MDSE are to significantly improve reusability and pro- ductivity in producing software for different implementation platforms. These are basically achieved by constructing the high-level (platform-independent) software models before-hand and then very efficiently, typically with the help of proven automated techniques and tools, applying these models to a new platform to generate the software for it. This application step makes extensive use of reusable assets, including software frameworks, components, architectures and models [16]. While the MDSE’s goal is ambitiously broad and encompassing, DDD [22] focuses more specifically on the problem of how to effectively use models to tackle the complexity inherent in the domain requirements. DDD’s goal is to develop software based on domain models that not only truly describe the domain but are technically feasible for implementation. According to Evans [22], object-oriented programming language (OOPL) is especially suited for use with DDD. This is not surprising, given that Booch [8] had ealier pointed out two 1 main reasons why OOPL would result in domain models that are inherently expressive and feasible. First, object naturally represents the (abstract) entities that are conceived to exist in real-world domains. Second, the construct of object used in OOPL is also a basic construct of high-level analysis and design modelling languages that are used to conceptualise and analyse the domain. The domain model, which is primarily studied under DDD and a type of model engineered in MDSE, is in fact the basis for specifying what had been called in the language engineering community as domain-specific language (DSL) [74]. The aim of DSL is to express the domain using concepts that are familiar to the domain experts. A key requirement in DSL engineering is to enable the domain experts and the technical team to focus on building the domain model, not having to worry about the technicality of language design. A type of DSL, called annotation-based DSL (aDSL) [25, 54], appears to satisfy this requirement. aDSL is an application of the annotation feature of modern OOPLs in DSL engineering. Before this, however, annotation (called attribute in C# [33]) was used in attribute-oriented programming (AtOP) [12, 13] to express meta-attributes and in behaviour interface specification language (BISL) [32] to define the specification structure. A key benefit of aDSL is that it is internal to the host OOPL and thus does not require a separate syntax specification. This helps significantly reduce development cost and increase ease-of- learning. In fact, simple forms of aDSL have been used quite extensively in both DDD and MDSE communities. In DDD, annotation-based extensions of OOPLs have been used to develop software frameworks (e.g. [17, 60]) that support the development of not only the domain model but the final software. The design rules in these models are expressed by a set of annotations. In MDSE, annotation sets are used to construct platform-specific models of software [4, 76, 77, 78]. Our initial research started out with an MBSD-typed investigation into a practical problem of how to improve the productivity of object-oriented software development [8, 43, 49, 51] using a Java-based design language for the domain model [44] and a software architectural model [45]. Placing these works in the context of DDD, MDSE and aDSL have given us an opportunity to advance our research to tackle a broader and more important problem concerning the DDD method for object-oriented software. 2 1.1 Problem Statement In this section, we will discuss the key challenges facing DDD for the object-oriented problem domains and define a research statement that is tackled in this disseration. We motivate our discussion using a software example, which we will also use throughout the dissertation to illustrate the concepts that are being presented. 1.1.1 Motivating Example Figure 1.1: A partial domain model of CourseMan. Our motivating example is a course management problem domain (abbr. CourseMan), which describes a compact, yet complete, domain that includes both structural and behavioural aspects. Figure 1.1 shows a partially completed CourseMan domain model expressed in the form of a UML class diagram [57]. Notationwise, in this dissertation, when it is necessary 3 to highlight the type of model element we will use a/an/the with name of the element type to refer to a particular element, and the plural form of this name to refer to a collection of elements. Further, we will use normal font for high-level concepts and fixed font for domain-specific and technical concepts. The bottom part of Figure 1.1 shows four classes and two association classes of Course- Man. Class Student represents the domain concept Student, who registers to study in an academic instituition. Class CourseModule represents the Course Modules1 that are offered by the institution. Class ElectiveModule represents a specialised type of CourseModule. Class SClass represents the student class type (morning, afternoon, or evening) for students to choose. Association class SClassRegistration captures details about the many-many association between Student and SClass. Finally, association class Enrolment captures details about the many-many association between Student and CourseModule. The top part of Figure 1.1 (the area containing a star-like shape with this label “?”) shows six other classes that are intended to capture the design of an activity called enrolment management. We know some design details (the attributes shown in the figure) and the following description about the six classes. We will give more details about the activity later in Chapter2. – HelpRequest: captures data about help information provided to students. – Orientation: captures data about orientation programs for newly-registered students. – Payment: captures data about payment for the intuition fee that a student needs to make. – Authorisation: captures data about the decision made by an enrolment officer con- cerning whether or not to allow a student to undertake the registered course modules. – EnrolmentApproval: captures data about the decision made by the enrolment officer concerning a student’s enrolment. – EnrolmentMgmt: represents the enrolment management activity. This activity involves registering Students, enrolling them into CourseModules and registering them into SClasses. In addition, it allows each Student to raise a HelpRequest. 1 we use class/concept name as countable noun to identify instances. 4 1.1.2 Domain-Driven Design Challenges Let us now outline the key challenges facing domain modelling in DDD and software devel- opment from the domain model. Understanding these challenges leads us to formulate a set of open issues for the research statement that we tackle in this dissertation. Essential Constraints The UML note boxes in Figure 1.1 shows examples of 11 kinds of constraints concerning class, field and association. These constraints appear frequently in real-world domain models [34, 48, 49, 57]. We describe these constraints below: 1. Class Payment is immutable, i.e. all objects of this class are immutable. 2. Field S...2) – Abstract syntax of Operation and the related concepts (see §9.6.2) – Abstract syntax of Class – a type of Classifier – and the related concepts (see §11.4.2) – Abstract syntax of Association and the related concepts (see §11.5.2) To ease look-up, we label each key element of the ASM with the section reference, within whose meta-model the element is defined. For instance, meta-concept Class is defined in the meta-model of §11.4.2. The ASM presented in Figure 2.1 includes two new meta-concepts: Attribute and Asso- ciation End. These meta-concepts, whose rectangles are filled in gray, are sub-types of the meta-concept Property. We use the two meta-concepts to differentiate between properties that are attributes and those that serve as association ends of associations. The former participate in the containment relationship between Class and Attribute, while the latter participate in the containment relationship between Association and Association End. Further, Class has a containment relationship with Association. The Essential OCL According to the OCL specification [56], OCL is a user-friendly, typed, formal language for constructing expressions on UML models. OCL expressions are side-effect-free and each has a type. Typical examples of OCL expressions are invariants and queries over a UML model. The OCL specification consists in two packages: type (§8.2) and expression (§8.3). The former defines the valid types for the expressions in the latter. In the type package, all OCL types are derived from Classifier3 (see UML specification §9.2.2). Two core OCL types 2 we use the symbol § to denote sections in the UML specification. 3 we use fixed font here to be consistent with the OCL’s notation style below. 19 Figure 2.2: The OCL expression meta-model (Adapted from §8.3 [56]). that are commonly used are CollectionType and TupleType. CollectionType has four sub-types, namely SetType, OrderedSetType, SequenceType and BagType, representing sets, order sets, sequences, and bags (resp.). CollectionType is parameterised with an element type and can be nested. A nested CollectionType is one whose element type is another CollectionType. The TupleType conveniently combines different types to form an aggregate type, called tuple. Each part of a tuple is represented by an attribute. An attribute is typed and is uniquely identified by a name. Similar to CollectionType, TupleType is also nested. This means that the attributes in a tuple can have their types defined as TupleTypes. The expression package, whose meta-model is shown in Figure 2.2, specifies the structure of OCL expression. Every OclExpression is typed, which is usually not explicitly stated but derived. The core structure of OclExpression is described by VariableExp and the CallExp’s type hierarchy. VariableExp is an expression that involves the declaration and (possibly initialisation) of a variable. The initialisation consists in another OclExpression, which is typically a LiteralExp (for writing a value) or a CallExp. CallExp is used to “call”, i.e. set up, another expression that either, for the subtype named FeatureCallExp, references the value of a model’s feature (e.g. attribute, operation and association end) or, for the subtype named LoopExp, performs a loop over a collection. This loop involves a 20 Variable that points to each element of the collection and one or more OclExpressions that define a condition against which the elements are checked. An OclExpression is defined in a context of a model element (e.g. a class, an attribute, a method, etc.). It is via this element that an OclExpression can navigate the model, through association chains, to access other model elements that are of interest. A special keyword self is available in every OclExpression for referring to the contextual element. To ease writing, this keyword is implicit if omitted. Example 2.1. Let us illustrate OCL by showing how it is used to express an invariant on the UML’s ASM in Figure 2.1. The invariant is taken from §11.8.1.8 of the UML specification [57], which states that an aggregation is a binary association: 1 context Association inv: 2 self.memberEnd->exists( 3 e | e.aggregation AggregationKind::none) 4 implies 5 (memberEnd->size() = 2 and 6 memberEnd->exists(aggregation = AggregationKind::none)) Line 1 uses the keyword context to specify the context of the invariant (keyword inv) to be an Association. The invariant is interpreted as being true for every Association instance (at all times). Lines 2–6 form the body of the invariant. It is an implication A → B, where A is specified at lines 2–3 and B is specified at lines 5–6. The keyword implies means →. Lines 2–3 form a CallExp that performs an operation called exists over the collection self.memberEnd. This operation returns true or false depending on whether there exists an element of the collection that satisfies the condition: e.aggregation AggregationKind::none. In this condition, e is a Variable that points to each collection element and AggregationKind::none means ‘not-an-aggregation’. Thus, the condition effectively means to find all Association Ends of the current Association instance that is an aggregation of some kind. Lines 5–6 state two conditions that hold for memberEnd (which is a short-form of self.memberEnd): (line 5) it contains exactly two elements (hence the association is bi- nary) and (line 6) at least one other Association End of the current Association is not an aggregation. The second condition consists in a negated expression of the one used in A. 21 Approaches for Specifying SDM Kleppe [39] states four general approaches to defining the SDM of a language. The first approach is denotational, which uses a mathematics-based formalism. The second approach is translational, which translates the language into another language whose semantics is known. The third approach is pragmatic, which uses a reference implementation of the language as a way of describing semantics. This is a special form of the translational approach, in which the implementation language’s semantics is known. The fourth approach is operational, which defines the run-time state structure using some form of state-transition system and maps the mogram execution to the transition actions (or operations) in this system. It is worth mentioning that Kleppe’s view of the SDM amounts to what is called in the programming language community as dynamic semantics (Chapter 7 of [39]). It is dynamic in the sense that the semantics relies on the run-time state change. From the programming language’s perspective, there is also a static semantics of a language, which does not rely on the run-time. This semantics describes the well-formedness of the language mograms and thus can be checked at compile-time. In principle, a mogram’s concrete representation (e.g. a piece of text or a graphical form) is processed to produce the mogram’s abstract form. Static semantic analysis is performed at the end of this process to check the well-formedness (including valid binding and typing) of the mogram. 2.1.4 Domain-Driven Design The general goal of domain-driven design (DDD)[22, 75] is to develop software iteratively around a realistic model of the application domain, which both thoroughly captures the domain requirements and is technically feasible for implementation. According to Evans [22], object- oriented programming languages (OOPLs), such as Java [3, 28], are a natural fit for use with DDD. This is not surprising, given that Booch [8] had ealier pointed out two main reasons why OOPL would result in domain models that are inherently expressive and feasible. First, object naturally represents the (abstract) entities that exist in real-world domains. Second, the construct of object used in OOPL is also a basic construct of high-level analysis and design modelling languages that are used to conceptualise and analyse the domain. In this dissertation, we use DDD to refer specifically to object-oriented DDD. Domain modelling is concerned with building a domain model for each subject area of interest of a domain. DDD considers domain model to be the core (or “heart” [22]) of software, which 22 is where the complexity lies. DDD has two key tenets [22, 75]: (1 - feasibility) a domain model is the code and vice versa, and (2 - satisfiability) the domain model satisfies the domain requirements that are captured in a shared language, called the ubiquitous language. This language is developed by both the domain experts and the technical members of the project team, in an iterative and agile process of investigating and analysing the domain requirements. In our view, these tenets are the motivation behind the main research thread in DDD that had led to the development of contemporary object-oriented DDD software frameworks (e.g. Apache-ISIS [17] (successor of Naked Objects [62]) and OpenXava [60]). The modelling languages of these works are constructed from some annotation-based extensions of OOPL. DDD Patterns The DDD method [22, 52] provides a set of eight design patterns that address two main problem types: (i) constructing the domain model (5 patterns) and (ii) managing the life cycle of domain objects (3 patterns). The five patterns of the first problem type include four patterns originally proposed by Evans [22] and one emerging pattern (named domain events) reported by Millet and Tune [52]. The four original patterns are: entities, value objects, services (a.k.a domain services [52]) and modules. The three patterns of the second problem type are: aggregates, factories and repositories. We argue that, unlike the pattern aggregates, the two patterns factories and repositories are strictly not specific to domain modelling. They are adaptations of well-known generic technical solutions that help improve the design quality of a software model. For these reasons, in this dissertation, the term “DDD patterns” will exclude the two patterns factories and repositories. entities. This pattern discusses how the concept of entity, which originates from concep- tual modelling [34], should be treated with special care in DDD. The key design consideration is that entity is an object defined fundamentally by its identity. This identity, which is typi- cally represented by an identity attribute, gives the entity a “thread of continuity” thoughout its life time. Each entity has a unique identity value, which typically does not change throughout its life time. Other types of attributes, associations and other features that are associated with an entity are defined based on the identity. For example, the 12 domain classes of the CourseMan domain model in Figure 1.1 are entity types. A domain object of each class is an entity. Although the designs of these classes are incomplete, each class is defined with an identity attribute. All but the 23 two classes CourseModule and ElectiveModule are defined with an identity attribute named id. CourseModule’s identity attribute is named code, which is inherited down to ElectiveModule. value objects. This pattern discusses a special type of object called value object that “represents a descriptive aspect of the domain that has no conceptual identity” [22]. What value object describes (its value) is more important than its identity. An example given in [22] is the Color object provided by Java. Each object has a distinct colour value that describes a specific colour. We argue, based on this and other similar examples in [22], that it would be better (for domain modelling purposes) to treat value object as a special type of entity that has an identifier, but this identifier is the only attribute of interest. The identifier values carry domain-specific information that are significant for a particular modelling purpose. We are not concerned with the associations that value object has with other entities, regardless of the fact that these associations typically exist in the domain model. Understanding value object this way helps easily relate the two patterns. For example, in the CourseMan’s domain model of Figure 1.1 there are two types of value objects. Both are modelled in UML as enumeration types. The first type is named PaymentStatus, which describes a fixed set of distinct status values for the Payment transaction. Two typical payment status values are approved and rejected. The second type is AuthorzStatus, which describes a fixed set of distinct status values for Authorisation of enrolment. Similar to Payment, the typical authorisation status values are also approved and rejected. services (a.k.a domain services [52]). This pattern describes system behaviours that do not fit the responsibility of entity. These behaviours operate on entities but typically do not need to maintain state information like entities. Therefore, these behaviours are defined in a special concept named services. Evans [22] notes that services actually exist not only in the domain model but in other parts of the software. For example, there would be infratructure services responsible for providing such low-level, shared behaviours as networking and data communication. There are also application services responsible for coordinating behaviours of domain objects from different domain classes. The distinction between this type of service and domain service is very subtle, because both service types involve coordinating the domain objects in some fashion. Basically, Evans states that if a service’s coordination logic is domain-specific then it is a domain service; otherwise it is an application service. 24 In the CourseMan’s domain model of Figure 1.1, for example, class EnrolmentMgmt is a type of service. It performs a domain-specific, activity-based logic which requires coordinating the behaviours defined by other domain classes in the model. domain events. This pattern describes when and how domain-specific events are mod- elled in the domain model. A domain event is an important occurrence that typically involves performing some domain logic over two or more entities (such as that performed by ser- vices). Our view is that, regarding to domain service design, services is the core pattern and domain events enhances this core behaviour. In an event, one (publisher) entity announces the event and other (subscriber) entities, who are interested in the event, are informed of the event and, in response, carry out the relevant pieces of the domain logic. The invocation of this logic can be carried out either synchronously or asynchronously (via messages). We argue that domain event may not be needed in the former case, because it simply provides an optional layer of indirection to services (at the cost of additional code). In the latter case, domain event is necessary because the publisher must not know the subscriber(s) directly. There are two main design solutions for domain events:(i) rely on the language support for events (e.g. C#’s event) and (ii) define a separate event management model that provides the publish and subscribe interface operations for entities to use. The latter solution is more generic as it can be applied regardless of the implementation language feature support. To illustrate domain events, let us consider an event that occurs when a particular Enrolment has a “Fail” finalGrade, which means the concerned Student has failed a CourseModule. In this case, Enrolment is the publisher and EnrolmentMgmt would be a suitable subscriber of the event. The latter is because EnrolmentMgmt, as explained in the services pattern, performs the domain service logic concerning the enrolment matters. modules. This pattern describes how the traditional concept of module in program- ming [51] is applied to the domain model. Evans [22] defines module as a sub-structure of the domain model that “brings together elements of the model with particularly rich concep- tual relationships”. If the modules of a domain model are designed with high cohesion and low coupling then the domain model can scale to handle more complex domain requirements. Evans generally suggests to use package to define modules, but allows the designer to have the flexibility of deciding what to place in each package. For example, we would place each domain class of the CourseMan’s domain model in Figure 1.1 into its own module. The auxiliary domain classes of a domain class (e.g. PaymentStatus is auxiliary to Payment) are placed in the domain class’s module. 25 aggregates. This pattern describes a stronger logical object grouping than module in that the object group is treated as a single unit. In an aggregate, there is a root entity that acts as the access point for other objects that are internal to the aggregate. Strong dependency associations exist between the root and the internal objects, so that outside objects only need to rely on the root to obtain information about the aggregate. Outside objects may only hold transient references to internal objects (obtained from the root). These references are used only within an operation. In addition to achieving enhanced modularity, aggregates helps enforce model integrity on the object group of the aggregate. For example, in the domain model of the CourseMan software, if we suppose that all the SClassRegistrations do not make sense outside the context of their SClasses then we could form an aggregate consisting of these two domain classes. SClass is the root entity, while SClassRegistration is internal to the aggregate. factories. This pattern is an adaptation of the well-known software design pattern named factory [27]. A factory takes the object creation responsibility burden away from both entities and the client. This helps reduce coupling between these two components, thereby enhancing the modularity of the model. repositories. This pattern is both an adaption and a generalisation of the object-relational mapping solution [35]. First, it is an adaption in the sense of taking the object-relational mapping and applying it to the domain model. In particular, it handles how an entity is stored in an underlying database and how to manage access to this database. Second, the pattern generalises the mapping in that it defines an abstraction layer on top of the underlying database and a set of generic operations for querying the entities. The abstraction takes the form of a repository – a space where the entities “live” and can be searched for. DDD with DSL The idea of combining DDD and DSL to raise the level of abstraction of the target code model has been advocated in [25] by both the DDD’s author and others. However, [25] does not discuss any specific solutions for the idea. Other works on combining DDD and DSL (e.g. Sculptor [68]) focus only on structural modelling and use an external rather than an internal DSL. A deeper analysis of the related works concerning DDD and DSL reveals two main reasons why internal DSL is particularly suited for DDD. First, designing the domain model 26 in an internal DSL helps determine the implementation feasibility of the domain model in a target OOPL. An external DSL requires a separate syntax specification and ensuring the correctness of this specification is a non-trivial task. Second, a domain model specified in an internal DSL can be treated as a program in the target OOPL. This allows the development team to leverage the capabilities of the language platform to not only process the model but to develop the software generator. This helps significantly reduce the development effort, compared to using an external DSL. 2.1.5 Model-View-Controller Architecture To construct software from the domain model requires an architectural model that conforms to the generic layered architecture [22, 75]. A key requirement of such model is that it positions the domain model at the core layer, isolating it from the user interface and other layers. Evans [22] suggests that the Model-View-Controller (MVC) architecture model [41, 70] is one such model. The existing DDD frameworks [17, 60, 62] support this suggestion by employing some form of MVC architecture in their designs. More generally in practical software development, MVC or its variants are adopted so that the software can have some sort of GUI to assist the development team in constructing it. This GUI is essential to getting the user feedback, because, at least up to recently and due primarily to the human factor of the development process, software construction can not be fully automated [26]. Our position in this dissertation is that the MVC architecture is the backbone of any DDD method that adopts the layered architecture. Technically, MVC is considered in [11] to be one of several so-called agent-based design architectures. The main benefit of MVC is that it helps make software developed in it inherently modular and thus easier to maintain. Software that are designed in MVC consists of three components: model, view and controller. The internal design of each of the three components is maintained independently with minimum impact on the other two components. Modularity can further be enhanced by applying the architecture at the module level. An example of this design is an agent-based design architecture named PAC [15]. This design creates a hierarchical design architecture, in which a software is composed from a hierarchy of software modules. A software module (called PAC object in [15] and agent in [11]) realises a coherent subset of the software functions in terms of the architectural components. 27 Conceptually, in a software designed with MVC and the DDD method, the model com- ponent is the domain model. It includes a set of domain classes that capture data about the entities of interest in the application domain. For example, the CourseMan domain model in Figure 1.1 includes 11 domain classes (ex- cluding EnrolmentMgmt) that represent 11 entities of interest. The view component of a software is a set of user interface (UI) classes that are used to present the domain classes. Each class presents to the user a coherent view of a domain class and to make it easy for her Figure 2.3: A UI class of the domain class to interact with this view. For instance, Fig- Student (Source: [45]). ure 2.3 shows an example of a UI class for capturing data about Student objects. For each UI class, there is a controller class re- sponsible for selecting (and causing the display of) the user interface and for handling the events that are caused by user actions performed on it. When an event occurs, the controller maps it to suitable state change operation(s), such as create and update, and invokes these to yield result. For example, if the user action is to create an object (e.g. the action induced by clicking the button labelled Create in Figure 2.3) then the controller would map it to an object instantiation operation of the concerned domain class and invoke this operation to create the object. The arguments of this invocation, if any, are the data that the user entered on the user interface. In Figure 2.3, for example, data include the values “Le Van Sau”, “1/1/1990”, “Ho Chi Minh”, “sau@gmail.com”, and “1c13” that the user input in the data fields of the UI class of Student. When the state of a domain object is changed, a change notification is sent to the corresponding UI class to request it to update the display. This class can query the model for details of this change before making the update. 2.1.6 Comparing and Integrating MDSE with DDD Understanding the comparison between MDSE and DDD helps determine the most suitable strategy for integrating the two methods. In principle, Brambilla et al. [9] suggest that MDSE 28 complements DDD by providing techniques (e.g. domain modelling and DSL engineering) which can help the development team benefit more from the domain model. They state that DDD and MDSE has two main similarities. First, both enforce the use of model in developing software. Second, both methods support models at different levels of abstraction (e.g. platform-independent and platform-dependent). However DDD differs from MDSE in three aspects. First, DDD follows a more agile approach to domain modelling, particularly that which relies on modern advance in OOPLs. Second, while DDD focuses primarily on the design and implementation phases, MDSE’s scope is wider and covers the entire development process. Third, although DDD acknowledges the role of model engineering, it also highlights the importance of a ubiquitous language that is used by all the human actors in the process. 2.1.7 A Core Meta-Model of Object-Oriented Programming Language It is clear that a DDD method for object-oriented software needs to use an object-oriented programming language (OOPL) as the target language for implementation. In his book [22], Evans uses Java [3, 28] to demonstrate the DDD method. We argue that because Java and another, also very popular, OOPL named C# [33] share the core features, we will generalise these features to form what we term a “generalised” OOPL. To ease notation, we will refer to this language simply as OOPL. We take the Kleppe’s view (see Section 2.1.3) that meta- modelling is applicable to any software language and apply it to review the OOPL’s ASM. In particular, we will focus on discussing the annotation feature. The concrete syntax and semantics of Java and C# are described in [28] and [33](resp.). Abstract Syntax Figure 2.4 shows a UML-based ASM of OOPL. This ASM includes the core meta-concepts that are supported by Java and C#. It excludes the meta-concepts that describe the struc- ture of the method body. Our scope of interest is on the class structure, not the code. Note, in particular, the following three design features of the OOPL ASM shown in the figure. First, meta-concept Class represents both class and interface (an interface is a class that has no fields). Second, meta-concept AnnotatedElement is modelled as super- type of four non-annotation meta-concepts: Class, Field, Method and Parameter. The association between AnnotatedElement and Annotation helps capture a general rule that 29 Annotation can be attached to any of the non-annotation meta-concept. Third, meta-concept Generalisation, which is adapted from UML/OCL (discussed in Section 2.1.3), captures the subclass-superclass relationship between classes. Basically, a class may consist of one or more generalisations, each of which must be related to exactly one superclass. Figure 2.4: The UML-based ASM of OOPL. Definition 2.2. An OOPL model (or model for short) is a structure that conforms to (or is an instance of) the OOPL’s meta-model. Denote by e : T a model element (or instance) e of some meta-concept T . For example, a Java model for expressing a domain sub-model of CourseMan (discussed in Section 1.1.1) would include the following three Classes: Student, CourseModule and Enrolment. These classes are instances of the meta-concept Class of Java. Annotation Because Annotation plays a key role in the construction of aDSL (discussed later in Sec- tion 2.1.8), we devote this section to discussing this meta-concept in detail. Annotation borrows its name from Java [3, 28]. The similar meta-concept in C# is called attribute [33]. Although annotation is syntactically defined as a Java interface it actually behaves like a class. This same view is also held for C#’s attribute. In this dissertation, we will promote Annotation to be a generic meta-concept that is applicable to both Java and C#. The reason that we choose the Java’s term will become clear shortly below. 30 Definition 2.3. Annotation (short for annotation type) is a meta-concept behaviourally equivalent to Class, that is designed for the purpose of being applied to other meta-concepts to present information about them in a uniform and structured fashion. The annotation instances are created at run-time for each model element to whose meta-concept the annotation is applied. The application of annotation is intuitively called annotation attachment. An annotation A may be attached to more than one non-annotation meta-concepts T = {T1, ..., Tn}. We write this as AT . When the context either does not require to identify or is clear as to what T in AT is, we will omit it and simply write AT as A. Example 2.2. To model that a domain class, such as Student, requires another resource to perform its behaviour, we would attach to it an annotation named Resource. For the sake of the example, we will borrow this annotation from the Java’s built-in annotation of the same name (javax.annotation.Resource). This annotation defines a reference to the target (actual) resource type. In fact, the annotation is attachable also to Field and Method. So we write: Resource{Class, Field, Method}. An annotation consists of properties. A property is called an annotation element in Java and a parameter in C#. Definition 2.4. An annotation property is characterised by name, data type, and default value. Data type is one of the followings: primitive type, string, enum, class, annotation, an array of one of the previous types. We call a property an annotation-typed property if its data type is defined from annotation (i.e. is an annotation or an array thereof). Notationwise, we use the dot notation to write annotation property; e.g. A.p denotes property p of an annotation A. An important note about Definition 2.4 is that the notion of annotation-typed property does not directly exist in C#. This is because in C# an annotation property cannot take an annotation as its data type. Fortunately, this shortcoming can be overcome...to teaching software engineering at Hanoi Univeristy should be documented, analysed and published. In addition, other works should be conducted to integrate the method into teaching at the entry level, which includes object-oriented programming course modules. 148 Publications During the development of this dissertation, the author has published in the following inter- national conferences and journals: 1. D. M. Le, D.-H. Dang, V.-H. Nguyen, “Domain-Driven Design Using Meta-Attributes: A DSL-Based Approach”, in: Proc. 8th Int. Conf. Knowledge and Systems Engineer- ing (KSE), IEEE, 2016, pp. 67–72. 2. D. M. Le, D.-H. Dang, V.-H. Nguyen, “Domain-Driven Design Patterns: A Metadata- Based Approach”, in: Proc. 12th Int. Conf. on Computing and Communication Technologies (RIVF), IEEE, 2016, pp. 247–252. 3. D. M. Le, D. H. Dang, V. H. Nguyen, “Generative Software Module Development: A Domain-Driven Design Perspective”, in: Proc. 9th Int. Conf. on Knowledge and Systems Engineering (KSE), 2017, pp. 77–82. 4. D. M. Le, D.-H. Dang, and V.-H.Nguyen, “On Domain Driven Design Using Annotation- Based Domain Specific Language,” Journal of Computer Languages, Systems & Struc- tures (SCIE), vol. 54, pp. 199–235, 2018. 5. D. M. Le, D.-H. Dang, H. T. Vu, “jDomainApp: A Module-Based Domain-Driven Software Framework”, in: Proc. 10th Int. Symp. on Information and Communication Technology (SOICT), ACM, 2019. 6. D. M. Le, D.-H. Dang, V.-H. Nguyen, “Generative Software Module Development for Domain-Driven Design with Annotation-Based Domain Specific Language”, Journal of Information and Software Technology (SCIE), vol. 120, pp. 106–239, 2020. 149 Bibliography [1] D. Akehurst et al., “Implementing Associations: UML 2.0 to Java 5,” Softw Syst Model, vol. 6, no. 1, pp. 3–35, Mar. 2007. [2] J. Alves-Foss and F. S. Lam, “Dynamic Denotational Semantics of Java,” in Formal Syntax and Semantics of Java, ser. Lecture Notes in Computer Science. Springer, Berlin, Heidelberg, 1999, pp. 201–240. [3] K. Arnold et al., The Java Programming Language, 4th ed. Addison-wesley Reading, 2005, vol. 2. [4] M. Balz, “Embedding Model Specifications in Object-Oriented Program Code: A Bottom-up Approach for Model-Based Software Development,” Ph.D. dissertation, Universität Duisburg-Essen, Jan. 2012. [5] M. Barnett et al., “The Spec# Programming System: An Overview,” in Construction and Analysis of Safe, Secure, and Interoperable Smart Devices, ser. Lecture Notes in Computer Science. Springer, Berlin, Heidelberg, Mar. 2004, pp. 49–69. [6] K. Beck et al., “Manifesto for Agile Software Development,” 2017. [7] D. Bogdanas and G. Roşu, “K-Java: a complete semantics of Java,” in ACM SIGPLAN Notices, vol. 50. ACM, 2015, pp. 445–456. [8] G. Booch, “Object-Oriented Development,” IEEE Transactions on Software Engineer- ing, vol. SE-12, no. 2, pp. 211–221, Feb. 1986. [9] M. Brambilla et al., Model-Driven Software Engineering in Practice, 2nd ed. Morgan & Claypool Publishers, Apr. 2017. 150 [10] D. Bruns, “Formal Semantics for the Java Modeling Language,” Ph.D. dissertation, 2009. [11] G. Calvary et al., “From Single-user Architectural Design to PAC*: A Generic Software Architecture Model for CSCW,” in ACM SIGCHI Conf. on Human Factors in Computing Systems, ser. CHI ’97. New York, NY, USA: ACM, 1997, pp. 242–249. [12] V. Cepa, Attribute Enabled Software Development. Saarbrücken, Germany, Germany: VDM Verlag, 2007. [13] V. Cepa and S. Kloppenburg, “Representing Explicit Attributes in UML,” in 7th Int. Workshop on Aspect-Oriented Modeling (AOM), 2005. [14] C. W. Churchman, The Systems Approach, revised, updated ed. New York, NY: Dell Publising Company, Nov. 1984. [15] J. Coutaz, “PAC: An Object Oriented Model for Dialog Design,” in Interact’87, vol. 87. Elsevier, 1987, pp. 431–436. [16] K. Czarnecki, “Overview of Generative Software Development,” in Unconventional Programming Paradigms, ser. Lecture Notes in Computer Science, J.-P. Banâtre et al., Eds. Springer Berlin Heidelberg, 2005, no. 3566, pp. 326–341. [17] Dan Haywood, “Apache Isis - Developing Domain-Driven Java Apps,” Methods & Tools: Practical knowledge source for software development professionals, vol. 21, no. 2, pp. 40–59, 2013. [18] DataNucleus, “JDO Annotations Reference (v5.1),” 2018. [19] R. Dekkers, Applied Systems Theory, 2nd ed. Springer International Publishing, 2017. [20] M. Dumas and A. H. M. t. Hofstede, “UML Activity Diagrams as a Workflow Specifica- tion Language,” in UML 2001, ser. LNCS, M. Gogolla and C. Kobryn, Eds. Springer, Oct. 2001, pp. 76–90. [21] Eclipse Foundation, “Eclipse Modeling Project,” 2019. URL: https://www.eclipse.org/ modeling/emf/ 151 [22] E. Evans, Domain-Driven Design: Tackling Complexity in the Heart of Software. Addison-Wesley Professional, 2004. [23] E. Evans, Domain-Driven Design Reference: Definitions and Pattern Summaries. Dog Ear Publishing, LLC, Sep. 2014. [24] E. Folmer and J. Bosch, “Architecting for Usability: A Survey,” Journal of Systems and Software, vol. 70, no. 1–2, pp. 61–78, Feb. 2004. [25] M. Fowler and T. White, Domain-Specific Languages. Addison-Wesley Professional, Sep. 2010. [26] A. Fuggetta and E. Di Nitto, “Software Process,” in Proceedings of the on Future of Software Engineering, ser. FOSE 2014. New York, NY, USA: ACM, 2014, pp. 1–12. [27] E. Gamma et al., Design Patterns: Elements of Reusable Object-Oriented Software, 1st ed. Reading, Mass: Addison-Wesley Professional, Nov. 1994. [28] J. Gosling et al., The Java Language Specification, Java SE 8 Edition, 1st ed. Upper Saddle River, NJ: Addison-Wesley Professional, May 2014. [29] J. Gosling et al., The Java Language Specification: Java SE 9 Edition. California, USA: Oracle America, Inc., Aug. 2017. [30] C. Guindon, “Eclipse OCL (Object Constraint Language),” Jan. 2013. [31] W. Harrison et al., “Mapping UML Designs to Java,” in Proc. 15th ACM SIGPLAN Conf. on Object-oriented Programming, Systems, Languages, and Applications, ser. OOPSLA ’00. New York, NY, USA: ACM, 2000, pp. 178–187. [32] J. Hatcliff et al., “Behavioral Interface Specification Languages,” ACM Comput. Surv., vol. 44, no. 3, pp. 16:1–16:58, Jun. 2012. [33] A. Hejlsberg et al., The C# Programming Language, 4th ed. Upper Saddle River, NJ: Addison Wesley, Oct. 2010. [34] J. A. Hoffer et al., Modern Systems Analysis and Design, 7th ed. Boston: Prentice Hall, Feb. 2013. 152 [35] J. A. Hoffer et al., Modern Database Management, 12nd ed. Boston: Pearson, Jul. 2015. [36] P. Hudak, “Modular Domain Specific Languages and Tools,” in Proc. 5th Int. Conf. on Software Reuse, Jun. 1998, pp. 134–142. [37] J. Juneau, “Java Modularity,” in Java 9 Recipes: A Problem-Solution Approach, J. Juneau, Ed. Berkeley, CA: Apress, 2017, pp. 605–614. [38] S. Kent, “Model Driven Engineering,” in Integrated Formal Methods, ser. Lecture Notes in Computer Science, M. Butler et al., Eds. Springer Berlin Heidelberg, May 2002, no. 2335, pp. 286–298. [39] A. Kleppe, Software Language Engineering: Creating Domain-Specific Languages Using Metamodels, 1st ed. Upper Saddle River, NJ: Addison-Wesley Professional, Dec. 2008. [40] T. Kosar et al., “Domain-Specific Languages: A Systematic Mapping Study,” Informa- tion and Software Technology, vol. 71, pp. 77–91, Mar. 2016. [41] G. E. Krasner and S. T. Pope, “A Description of the Model-View-Controller User Inter- face Paradigm in the Smalltalk-80 System,” Journal of object-oriented programming, vol. 1, no. 3, pp. 26–49, 1988. [42] A. v. Lamsweerde, “Formal Specification: A Roadmap,” in Proceedings of the Confer- ence on The Future of Software Engineering, ser. ICSE ’00. New York, NY, USA: ACM, 2000, pp. 147–159. [43] C. Larman, Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, 3rd ed. Upper Saddle River, NJ, USA: Prentice Hall PTR, 2004. [44] D. M. Le, “A Domain-Oriented, Java Specification Language,” in Proc. 7th Int. Conf. Knowledge and Systems Engineering (KSE). IEEE, Oct. 2015, pp. 25–30. [45] D. M. Le, “A Tree-Based, Domain-Oriented Software Architecture for Interactive Object-Oriented Applications,” in Proc. 7th Int. Conf. Knowledge and Systems En- gineering (KSE). IEEE, Oct. 2015, pp. 19–24. 153 [46] G. T. Leavens, “JML Reference Manual,” Tech. Rep., 2013. [47] G. T. Leavens et al., “Preliminary Design of JML: A Behavioral Interface Specification Language for Java,” SIGSOFT Softw. Eng. Notes, vol. 31, no. 3, pp. 1–38, May 2006. [48] B. Liskov and J. Guttag, Abstraction and specification in program development. MIT Press, 1986. [49] B. Liskov and J. Guttag, Program Development in Java: Abstraction, Specification, and Object-Oriented Design. Pearson Education, 2000. [50] M. Mernik et al., “When and How to Develop Domain-specific Languages,” ACM Comput. Surv., vol. 37, no. 4, pp. 316–344, Dec. 2005. [51] B. Meyer, Object-Oriented Software Construction, 2nd ed. Santa Barbara (California): ISE Inc., 1997. [52] S. Millett and N. Tune, Patterns, Principles, and Practices of Domain-Driven Design. John Wiley & Sons, Apr. 2015. [53] M. Nosál and J. Porubän, “XML To Annotations Mapping Definition With Patterns,” Computer Science and Information Systems, vol. 11, no. 4, pp. 1455–1477, 2014. [54] M. Nosál’ et al., “Language Composition Using Source Code Annotations,” Computer Science and Information Systems, vol. 13, no. 3, pp. 707–729, 2016. [55] OMG, “Model Driven Architecture (MDA),” OMG, Tech. Rep. ormsc/2001-07-01, Jul. 2001. [56] OMG, “Object Constraint Language Version 2.4,” OMG, Tech. Rep. formal/2014-02-03, 2014. [57] OMG, “Unified Modeling Language version 2.5,” OMG, Tech. Rep. formal/2015-03-01, 2015. [58] OMG, “Meta Object Facility (MOF) Core Specification,” OMG, Tech. Rep. formal/15- 06-06, Nov. 2016. [59] Oracle, “Java Persistence API Specification,” 2018. 154 [60] J. Paniza, Learn OpenXava by Example. CreateSpace Independent Publishing Plat- form, 2011. [61] Paul Deitel, “Understanding Java 9 Modules,” 2017. [62] R. Pawson and R. Matthews, “Naked Objects,” in OOPSLA ’02, ser. OOPSLA ’02. New York, NY, USA: ACM, 2002, pp. 36–37. [63] Red Hat, “Bean Validation 2.0 (JSR 380),” 2017. [64] Red Hat, “Hibernate Validator,” 2017. [65] D. Riehle and H. Züllighoven, “Understanding and Using Patterns in Software Devel- opment,” Theory Pract. Obj. Syst., vol. 2, no. 1, pp. 3–13, Jan. 1996. [66] P. Runeson and M. Höst, “Guidelines for Conducting and Reporting Case Study Research in Software Engineering,” Empir Software Eng, vol. 14, no. 2, p. 131, Apr. 2009. URL: [67] D. C. Schmidt, “Model-Driven Engineering,” Computer, vol. 39, pp. 25–31, 2006. [68] Sculptor Team, “Sculptor - Generating Java Code From DDD-Inspired Textual DSL,” 2016. URL: [69] G. Smith, The Object-Z Specification Language, ser. Advances in Formal Methods. Boston, MA: Springer US, 2000, vol. 1. [70] I. Sommerville, Software Engineering, 9th ed. Pearson, 2011. [71] J. M. Spivey, “An Introduction to Z and Formal Specifications,” Software Engineering Journal, vol. 4, no. 1, pp. 40–50, Jan. 1989. [72] M. Sulír et al., “Recording Concerns In Source Code Using Annotations,” Computer Languages, Systems & Structures, vol. 46, pp. 44–65, Nov. 2016. [73] F. Tomassetti et al., “JavaParser,” 2016. URL: [74] A. van Deursen et al., “Domain-Specific Languages: An Annotated Bibliography,” SIGPLAN Not., vol. 35, no. 6, pp. 26–36, Jun. 2000. 155 [75] V. Vernon, Implementing Domain-Driven Design, 1st ed. Upper Saddle River, NJ: Addison-Wesley Professional, Feb. 2013. [76] H. Wada and J. Suzuki, “Modeling Turnpike Frontend System: A Model-Driven Devel- opment Framework Leveraging UML Metamodeling and Attribute-Oriented Program- ming,” in Model Driven Engineering Languages and Systems, ser. Lecture Notes in Computer Science, L. Briand and C. Williams, Eds. Springer Berlin Heidelberg, Oct. 2005, no. 3713, pp. 584–600. [77] J. B. Warmer and A. G. Kleppe, “Building a Flexible Software Factory Using Partial Domain Specific Models,” Oct. 2006. [78] J. Warmer, “A Model Driven Software Factory Using Domain Specific Languages,” in Model Driven Architecture- Foundations and Applications. Springer, Berlin, Heidel- berg, Jun. 2007, pp. 194–203. 156 Appendices 157 Appendix A Helper OCL Functions for DCSL’s ASM ExprTk Figure A.1: Utility class ExprTk. 1 context ExprTk::genLinkRemoverPreCond(c: Classifier, m : Parameter, y : Integer) : String 2 -- return a pre-condition for a link-remover operation depending on m. type 3 post : 4 let ty : Classifier = m.type in 5 let cname : String = c.name.at(1).toLowerCase() + c.name.substring(2,c. name.size()) in 6 if ty.oclIsKindOf(CollectionType) then 7 result = cname+’Count - ’+m.name+’.size() >= ’ + y 8 else 9 result = cname+’Count - 1 >= ’ + y 10 endif 158 11 12 context ExprTk::genLinkRemoverPostCond1(a: Field, m : Parameter) : String 13 -- return post-condition (1) for a link-remover operation depending on m. type 14 pre: a.type.oclIsKindOf(CollectionType) 15 post : 16 let ty : Classifier = m.type in 17 if ty.oclIsKindOf(CollectionType) then 18 result = a.name+’ = ’+a.name+’@pre->asSet() - ’+m.name+’->asSet()’ 19 else 20 result = a.name+’ = ’+a.name+’@pre->asSet() - Set{’+m.name+’}’ 21 endif 22 23 context ExprTk::genLinkRemoverPostCond2(c: Classifier, a: Field) : String 24 -- return post-condition (2) for a link-remover operation depending on m. type 25 pre: a.type.oclIsKindOf(CollectionType) 26 post : 27 let cname : String = c.name.at(1).toLowerCase() + c.name.substring(2,c. name.size()) in 28 result = cname+’Count = ’+a.name+’->size()’ 29 30 context ExprTk::genLinkAdderPreCond(c: Classifier, m : Parameter, x : Integer) : String 31 -- return a pre-condition for a link-adder operation depending on m.type 32 post : 33 let ty : Classifier = m.type in 34 let cname : String = c.name.at(1).toLowerCase() + c.name.substring(2,c. name.size()) in 35 if ty.oclIsKindOf(CollectionType) then 36 result = cname+’Count + ’+m.name+’.size() <= ’ + x 37 else 38 result = cname+’Count + 1 <= ’ + x 39 endif 40 41 context ExprTk::genLinkAdderPostCond1(a: Field, m : Parameter) : String 42 -- return post-condition (1) for a link-adder operation depending on m. type 43 pre: a.type.oclIsKindOf(CollectionType) 44 post : 45 let ty : Classifier = m.type in 46 if ty.oclIsKindOf(CollectionType) then 47 result = a.name+’ = ’+a.name+’@pre->asSet()->union(’+m.name+’->asSet ())’ 159 48 else 49 result = a.name+’ = ’+a.name+’@pre->asSet()->union(Set{’+m.name+’})’ 50 endif 51 52 context ExprTk::genLinkAdderPostCond2(c: Classifier, a: Field) : String 53 -- return post-condition (2) for a link-remover operation depending on m. type 54 pre: a.type.oclIsKindOf(CollectionType) 55 post: result = genLinkRemoverPostCond2(c, a) Tk Figure A.2: Utility class Tk. 1 context Tk::isLinkTo(o1: Object, a: Field, o2 : Object) : Boolean 2 -- check if a.value(o1) contains a link to o2 3 post : 4 let v1 = a.value(o1) in 5 if a.type.oclIsKindOf(CollectionType) then v1->includes(o2) else v1 = o2 endif 6 7 context Tk::ancestors(c: Class) : Set(Class) 8 -- return ancestor classes of c 9 post : 10 if not(c.gens.oclIsUndefined()) then 11 result = c.gens->collect(g | 12 {g.super}.union(ancestors(g.super))->excluding(OclVoid))->flatten()-> asSet () 13 else 14 result = OclVoid 15 endif 160 Classifier 1 context Classifier 2 -- if this conforms to CollectionType then return elementType else return self 3 def: elementType() : Classifier = 4 if oclIsKindOf(CollectionType) then oclAsType(CollectionType). elementType else self endif Class 1 context Class 2 -- return all link-remover methods of this 3 def: linkRemovers() : Set(Method) = 4 methods->select(m | m.opt.type = OptType::LinkRemover) 5 6 -- return all link-adder methods of this 7 def: linkAdders() : Set(Method) = 8 methods->select(m | m.opt.type = OptType::LinkAdder) 9 10 -- return all overriden methods of this 11 def: overridenMethods() : Set(Method) = 12 methods->select(m | m.annotations->select(n | n.name = ’Overriden’)-> size () = 1) Method 1 context Method 2 -- return the post-condition exprs of a method 3 def: postExps() : Sequence(OclExpression) = 4 post.specification.oclAsType(OpaqueExpression). 5 body.oclAsType(Sequence(OclExpression)) 6 7 -- return the pre-condition exprs of a method 8 def: preExps() : Sequence(OclExpression) = 9 pre.specification.oclAsType(OpaqueExpression). 10 body.oclAsType(Sequence(OclExpression)) 11 12 -- return the result expression of the form "result = ..." 13 def: resultExp() : OclExpression = 14 if postExps()->size() = 1 and 161 15 postExps()->any(true).oclIsType(VarAssignExpression) then 16 postExps()->any(true).oclAsType(VarAssignExpression) 17 else 18 OclVoid 19 endif 20 21 22 -- is this an overriden method 23 def: isOverriden() : Boolean = (annotations->select(n | n.name = ’ Overriden’)->size() = 1) 24 25 -- is this the mutator method 26 def: isAttrRef(a: Field) : Boolean = (ref.value = a.name) 27 28 -- is this a creator method or a mutator method that references a? 29 def: isCreatorOrMutatorRef(a: Field) : Boolean = 30 isCreatorRef(a) or isMutatorRef(a) 31 32 -- is this a creator method that contains a parameter referencing a? 33 def: isCreatorRef(a: Field) : Boolean = 34 isCreator() and params->exists(isAttrRef(a)) 35 36 -- is this a mutator method that contains a parameter referencing a? 37 def: isMutatorRef(a: Field) : Boolean = 38 isMutator() and params->exists(isAttrRef(a))) 39 40 -- is this the creator method 41 def: isCreator() : Boolean = (opt.type = OptType::Creator) 42 43 -- is this the mutator method 44 def: isMutator() : Boolean = (opt.type = OptType::Mutator) Parameter 1 context Parameter 2 -- does this reference a? 3 def: isAttrRef(a: Field) : Boolean = (ref.value = a.name) Field 1 context f: Field 2 -- determine if a field has numeric type 162 3 def: isNumericType() : Boolean = 4 let tyn : String = f.type.name in 5 tyn = ’Integer’ or tyn = ’Real’ or tyn = ’UnlimitedNatural’ DAttr 1 context DAttr 2 -- does this preserve another DAttr? 3 def: preserves(r: DAttr) : Boolean = 4 mutable = r.mutable and optional = r.optional and unique = r.unique and id = r.id and 5 auto = r.auto and length <= r.length and 6 min Double::INFINITY implies min >= r.min and 7 max Double::INFINITY implies max <= r.max OclExpression 1 context e: OclExpression 2 -- check if the string representation of this is equal to the argument 3 def: equals(s: String) : Boolean = 4 e.toString().equals(s) 163 Appendix B MCCL Specification B.1 Library Rules of the MCCL’s ASM ModuleConfig R28 1 context ModuleConfig 2 -- if this is a composite module then return the set of ModuleConfigs of the 3 -- descendant modules else return {} (empty set). 4 -- (this does not depend on whether contTree is specified or not) 5 def: descMods() : Set(ModuleConfig) = 6 if isComposite() 7 then 8 let G : Set(ModuleConfig) = model.domainClass.assocFields->collect(f | 9 MCCModel::getInstance()::lookUpModuleCfg(f.type))->asSet() 10 in 11 G.union(G->iterate(g; G1 : Set(Set(ModuleConfig)) = Set{}) | 12 G1->including(descMods(g)))->flatten() 13 else 14 {} 15 endif 16 17 -- if g is composite then return the ModuleConfigs of the descendant modules 18 -- else return {} 19 def: descMods(g: ModuleConfig) : Set(ModuleConfig) = 20 if g.isComposite() then 164 21 g.descMods() 22 else 23 {} 24 endif 25 26 -- return the ModuleConfig of the descendant module of this in t whose 27 -- domain class is mapped to n 28 def: getDescModuleOf(n : Node) : ModuleConfig = 29 descMods()->select(model.domainClass = n.dclass)->any() 30 31 -- if this is a composite module return true else return false 32 def: isComposite() : Boolean = model.domainClass.assocFields->notEmpty() Class R29 1 context Class 2 -- if self contains domain fields then return them as Set else return {} 3 def: domFields() : Set(Field) = 4 fields->select(f | not(f.atr.oclIsUndefined())) 5 6 -- if self contains a domain field whose name is n then return it else return OclVoid 7 def: getDomField(n : String) : Field = 8 let F : Set(Field) = fields->select(f | not(f.atr.oclIsUndefined()) and f . name = n) 9 in 10 if F->notEmpty() then F->any() else OclVoid endif 11 12 -- if self contains associative domain fields then return them as Set else return {} 13 def: assocFields() : Set(Field) = 14 fields->select(f | not(f.atr.oclIsUndefined()) and not(f.asc. oclIsUndefined())) 15 16 -- whether or not self is a domain class (i.e. is defined with DClass) 17 def: isDomainClass() : Boolean = not(dcl.oclIsUndefined()) 165 Containment Tree R30 1 context Tree 2 -- determines if there is a path (i.e. a sequence of edges) that 3 -- connect n1 to n2 (in either direction) 4 def : hasPath(n1 : Node, n2 : Node) : Boolean = 5 edges->exists((parent = n1 and child = n2) or (parent = n2 and child = n1 )) 6 or 7 nodes->exists(n3 | hasPath(n1,n3) and hasPath(n3,n2)) R31 1 context Tree 2 -- return set of pairs (n : Node, s : String) such that n is the root or a child node 3 -- and s is the containment scope string of n.edge or of the ScopeConfig of the Edge 4 -- in which n is the child 5 def: getContScopes() : Set(Tuple(n : Node, s : String)) = 6 let C : Set(Tuple(n : Node, s : String)) = 7 edges->select(e | not(e.scope.stateScope.oclIsUndefined())) 8 ->collect(e | Tuple{ n = e.child, s = e.scope.stateScope} )-> asSet () 9 in 10 if not(root.stateScope.oclIsUndefined()) 11 then 12 { Tuple{ n = root, s = root.stateScope }.union(C) 13 else 14 C 15 endif Tk R32 1 context Tk::parseContScope(s : String) : Set(String) 2 -- if s contains ‘,’ then split s into elements (using ‘,’ as separator) 3 -- and return them as Set, else return {s} 4 pre: s.indexOf(‘,’) > 0 implies s.size() >= 3 5 post : 6 result = splitStr(s, ‘,’) 166 R33 1 context Tk::splitStr(s : String, p : String) : Set(String) 2 -- if s contains p then split s into elements (using p as separator) 3 -- and return them as Set, else return {s} 4 pre: p.size() = 1 and (s.indexOf(p) > 0 implies s.size() >= 3) 5 post : 6 let i : Integer = s.indexOf(p) in 7 if i > 0 8 then 9 result = splitStr(s.substring(0,i-1), p).union( 10 splitStr(s.substring(i+1, s.size()),p)) 11 else 12 result = {s} 13 endif MCCModel In the next OCL rule, we assume the existence of the attribute MCCModel.mcfgs whose type is Set(ModuleConfig). This attribute records all the ModuleConfigs of all the software modules. R34 1 context MCCModel 2 -- return the ModuleConfig of the owner module of c 3 def: lookUpModuleConfig(c: Class) : ModuleConfig = 4 mcfgs->select(model.domainClass = c)->any() B.2 Two MCCs of ModuleEnrolmentMgmt Listing B.1: The MCC of ModuleEnrolmentMgmt with containment tree 1 @ModuleDesc( 2 name="ModuleEnrolmentMgmt", 3 modelDesc=@ModelDesc(model=EnrolmentMgmt.class), 4 viewDesc =@ViewDesc(formTitle="Manage Enrolment Management",imageIcon=" enrolment.jpg", 5 domainClassLabel="Enrolment Management", 6 view = View .class,parentMenu=RegionName.Tools,topX=0.5,topY=0.0), 7 controllerDesc=@ControllerDesc(controller=Controller.class), 8 containmentTree=@CTree(root=EnrolmentMgmt.class, 167 9 edges ={ 10 // enrolmentmgmt -> student 11 @CEdge(parent=EnrolmentMgmt.class,child=Student.class, 12 scopeDesc=@ScopeDesc( 13 stateScope={"id", "name", "helpRequested", "modules"} 14 ))}) 15 ) 16 public class ModuleEnrolmentMgmt { 17 @AttributeDesc(label="Enrolment Management") 18 private String title; 19 20 // student registration 21 @AttributeDesc(label="Student Registration", 22 layoutBuilderType=TwoColumnLayoutBuilder.class 23 ,controllerDesc=@ControllerDesc( 24 openPolicy=OpenPolicy.I 25 // support many-many association with CourseModule 26 ,props ={ 27 // custom Create: to create {@link Enrolment} from the course modules 28 @PropertyDesc(name=PropertyName.controller_dataController_create, 29 valueIsClass=CreateObjectAndManyAssociatesDataControllerCommand.class , 30 valueAsString=MetaConstants.NullValue,valueType=Class.class), 31 // custom Update command: to update {@link Enrolment} from the course modules 32 @PropertyDesc(name=PropertyName.controller_dataController_update, 33 valueIsClass=UpdateObjectAndManyAssociatesDataControllerCommand.class , 34 valueAsString=MetaConstants.NullValue,valueType=Class.class) 35 }) 36 ) 37 private Collection students; 38 39 // help desk 40 @AttributeDesc(label="Help Request",type=DefaultPanel.class) 41 private Collection helpDesks; 42 43 // class registration 44 @AttributeDesc(label="Class Registration",type=DefaultPanel.class) 45 private Collection sclassRegists; 46 } 168 Listing B.2: The MCC of ModuleEnrolmentMgmt with custom subview configuration for a descendant module of type ModuleStudent 1 @ModuleDesc( 2 name="ModuleEnrolmentMgmt2", 3 modelDesc=@ModelDesc(model=EnrolmentMgmt.class), 4 viewDesc =@ViewDesc(formTitle="Manage Enrolment Management",imageIcon=" enrolment.jpg", 5 domainClassLabel="Enrolment Management", 6 view = View .class,parentMenu=RegionName.Tools,topX=0.5,topY=0.0), 7 controllerDesc=@ControllerDesc(controller=Controller.class), 8 containmentTree=@CTree(root=EnrolmentMgmt.class, 9 edges ={ 10 // enrolmentmgmt -> student 11 @CEdge(parent=EnrolmentMgmt.class, child=Student.class, 12 scopeDesc=@ScopeDesc( 13 stateScope={"id", "name", "helpRequested", "modules"} 14 // custom configuration for ModuleStudent 15 ,attribDescs={ 16 // Student.name is not editable 17 @AttributeDesc(id="id", type=JLabelField.class), 18 @AttributeDesc(id="name", type=JLabelField.class, editable=false), 19 }) 20 )}) 21 ) 22 public class ModuleEnrolmentMgmt2 { 23 @AttributeDesc(label="Enrolment Management") 24 private String title; 25 26 // student registration 27 @AttributeDesc(label="Student Registration", 28 layoutBuilderType=TwoColumnLayoutBuilder.class 29 ,controllerDesc=@ControllerDesc( 30 openPolicy=OpenPolicy.I 31 // support many-many association with CourseModule 32 ,props ={ 33 // custom Create: to create {@link Enrolment} from the course modules 34 @PropertyDesc(name=PropertyName.controller_dataController_create, 35 valueIsClass=CreateObjectAndManyAssociatesDataControllerCommand.class , valueAsString=MetaConstants.NullValue, valueType=Class.class), 36 // custom Update: to update {@link Enrolment} from the course modules 37 @PropertyDesc(name=PropertyName.controller_dataController_update, 38 valueIsClass=UpdateObjectAndManyAssociatesDataControllerCommand.class , valueAsString=MetaConstants.NullValue, valueType=Class.class) 169 39 }) 40 ) 41 private Collection students; 42 43 // help desk 44 @AttributeDesc(label="Help Request",type=DefaultPanel.class) 45 private Collection helpDesks; 46 47 // class registration 48 @AttributeDesc(label="Class Registration",type=DefaultPanel.class) 49 private Collection sclassRegists; 50 } 170 Appendix C DCSL Evaluation Data C.1 Expressiveness Comparison Between DCSL and the DDD Frameworks Table C.1: Comparing the expressiveness of DCSL to AL, XL DCSL AL XL DClass mutable DomainObject.editing – DAttr unique – (i) - jdo(ii).Column.allowsNull, optional Required (Property.optionality) mutable Property.editing - id jdo.PrimaryKey.value jpa.Id auto – – (iii) jdo.Column.length, length jpa(iv).Column.length (Property.maxLength) min – Min(v).value max – Max(v).value DAssoc 171 ascName – – jpa.OneToMany, ascType – jpa.ManyToOne, jpa.ManyToMany role – – endType – – associate.type – – associate.cardMin – – associate.cardMax – – DOpt type – – requires – – effects – – AttrRef value – – (i) AL supports property Property.mustSatisfy which may be used to implement the constraint. (ii) Java Data Objects (JDO) [18]. (iii) XL supports property ha.Formula that may be use to implement formula for value generation function. (iv) Java Persistence API (JPA) [59]. (v) Bean Validator (BV) [63]. 172 C.2 Level of Coding Comparison Between DCSL and the DDD Frameworks Table C.2: Comparing the max-locs of DCSL to AL, XL DCSL AL XL Domain Class DomainObject.editing, Entity, DClass.mutable autoCompleteRepository EntityValidator.value Domain Field Required, one-of { Column.allowsNull, name, Column.length, scale }, DAttr.length, min, max one-of { length, scale }, PropertyValidator.value, jdbcType Min.value, Max.value, SearchKey Associative Field DAssoc.ascName, ascType, role, endType; one-of { OneToMany, associate.type, – ManyToOne, ManyToMany} associate.cardMin, associate.cardMax 173 Table C.3: Comparing the typical-locs of DCSL to AL, XL DCSL AL XL Domain Class DomainObject.editing, Entity, DClass.mutable autoCompleteRepository EntityValidator.value Domain Field one-of { Column.length, one-of { DAttr.length, one-of { Column.length, Column.scale, Min.value, min, max } scale } Max.value } Associative Field DAssoc.ascName, ascType, role, endType; one-of { OneToMany, associate.type, – ManyToOne, ManyToMany} associate.cardMin, associate.cardMax 174

Các file đính kèm theo tài liệu này:

  • pdfluan_an_phuong_phap_tiep_can_khung_nhin_hop_nhat_cho_tu_dong.pdf