Abstract
Modularization and reuse are essential for the productivity of software development. Role-oriented programming complements the concepts of object-oriented programming with the goal to improve modularization. The programming language Object Teams, a role-oriented extension of the Java language, provides specific support for modularization of collaborations between objects. A class or object can play different roles in separate contexts. The realization of roles and context is supported in Object Teams through special classes. A role class defines a relationship, which is similar to inheritance, to a so called base class that plays the role. Roleplaying on the one hand allows a finer and more flexible modularization of context-specific data and functions, but on the other hand also leads to a strong coupling of the classes involved and thus has a negative impact on the reusability. This is due to the inability to abstract the binding between role and base. The goal of this work is to reduce the strong coupling between the classes involved and to improve both their flexibility and their reusability. Our approach introduces mechanisms for the abstraction of classes, which primarily allow expressing structural dependencies between role and base classes in a generic form. Such generic classes represent templates that are transformed depending on the specific application in which they are used. Metavariables can be used instead of static definitions in selected positions of the source code of the class. Metavariables represent placeholders for specific program elements such as classes and methods and provide a form of metaprogramming. A declarative description language, which is similar to logic programming in Prolog, is introduced for the specific definition of the metavariables. This allows the programmer to select specific program elements based on their structural properties – regardless of their identifiers. This way the function of a role may be defined in a generic form. The specific base classes and their methods that are to be bound to the role for a specific application are automatically identified based on the declarative description. The concrete form of a generic class is created for each new application by replacing the metavariables with specific program elements, depending on the respective context. As part of the compilation process of the program, the generic elements will be transformed into executable code. In this work we analyze the problems of Object Teams regarding modularization and reusability. Based on the analysis, the newly developed language extension Generic Object Teams, which extends Object Teams to include the options described for metaprogramming, is presented with syntax and semantics. The extension includes the mapping and evaluation of the program in Prolog. The effect on the modularization and reusability of the new language features will be evaluated with a study of design pattern applications. This work shows that metaprogramming in Prolog can be successfully integrated into Object Teams. The developed approach improves the modularization and reusability, but also leads to an increased complexity of programs. The complexity raises the demands on the programmer and therefore limits the applicability of the approach. In summary, we consider the approach a useful contribution for role-oriented programming in Object Teams, which can serve as an inspiration and a basis for further developments in this area.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.